Struct dioxus_signals::CopyValue
source · pub struct CopyValue<T: 'static> { /* private fields */ }
Expand description
CopyValue is a wrapper around a value to make the value mutable and Copy.
It is internally backed by generational_box::GenerationalBox
.
Implementations§
source§impl<T: 'static> CopyValue<T>
impl<T: 'static> CopyValue<T>
sourcepub fn new(value: T) -> Self
pub fn new(value: T) -> Self
Create a new CopyValue. The value will be stored in the current component.
Once the component this value is created in is dropped, the value will be dropped.
sourcepub fn new_in_scope(value: T, scope: ScopeId) -> Self
pub fn new_in_scope(value: T, scope: ScopeId) -> Self
Create a new CopyValue. The value will be stored in the given scope. When the specified scope is dropped, the value will be dropped.
sourcepub fn origin_scope(&self) -> ScopeId
pub fn origin_scope(&self) -> ScopeId
Get the scope this value was created in.
sourcepub fn try_read(&self) -> Option<Ref<'_, T>>
pub fn try_read(&self) -> Option<Ref<'_, T>>
Try to read the value. If the value has been dropped, this will return None.
sourcepub fn read(&self) -> Ref<'static, T>
pub fn read(&self) -> Ref<'static, T>
Read the value. If the value has been dropped, this will panic.
sourcepub fn try_write(&self) -> Option<RefMut<'static, T>>
pub fn try_write(&self) -> Option<RefMut<'static, T>>
Try to write the value. If the value has been dropped, this will return None.
sourcepub fn write(&self) -> RefMut<'static, T>
pub fn write(&self) -> RefMut<'static, T>
Write the value. If the value has been dropped, this will panic.
source§impl<T: 'static> CopyValue<Vec<T>>
impl<T: 'static> CopyValue<Vec<T>>
source§impl<T: 'static> CopyValue<Option<T>>
impl<T: 'static> CopyValue<Option<T>>
sourcepub fn get_or_insert(&self, default: T) -> Ref<'_, T>
pub fn get_or_insert(&self, default: T) -> Ref<'_, T>
Gets the value out of the Option, or inserts the given value if the Option is empty.
sourcepub fn get_or_insert_with(&self, default: impl FnOnce() -> T) -> Ref<'_, T>
pub fn get_or_insert_with(&self, default: impl FnOnce() -> T) -> Ref<'_, T>
Gets the value out of the Option, or inserts the value returned by the given function if the Option is empty.
Trait Implementations§
source§impl<T: Add<Output = T> + Copy + 'static> AddAssign<T> for CopyValue<T>
impl<T: Add<Output = T> + Copy + 'static> AddAssign<T> for CopyValue<T>
source§fn add_assign(&mut self, rhs: T)
fn add_assign(&mut self, rhs: T)
+=
operation. Read moresource§impl<T: Div<Output = T> + Copy + 'static> DivAssign<T> for CopyValue<T>
impl<T: Div<Output = T> + Copy + 'static> DivAssign<T> for CopyValue<T>
source§fn div_assign(&mut self, rhs: T)
fn div_assign(&mut self, rhs: T)
/=
operation. Read moresource§impl<T: Mul<Output = T> + Copy + 'static> MulAssign<T> for CopyValue<T>
impl<T: Mul<Output = T> + Copy + 'static> MulAssign<T> for CopyValue<T>
source§fn mul_assign(&mut self, rhs: T)
fn mul_assign(&mut self, rhs: T)
*=
operation. Read moresource§impl<T: 'static> PartialEq<CopyValue<T>> for CopyValue<T>
impl<T: 'static> PartialEq<CopyValue<T>> for CopyValue<T>
source§impl<T: Sub<Output = T> + Copy + 'static> SubAssign<T> for CopyValue<T>
impl<T: Sub<Output = T> + Copy + 'static> SubAssign<T> for CopyValue<T>
source§fn sub_assign(&mut self, rhs: T)
fn sub_assign(&mut self, rhs: T)
-=
operation. Read more