pub struct CopyValue<T: 'static, S: Storage<T> = UnsyncStorage> { /* 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.
Source§impl<T: 'static, S: Storage<T>> CopyValue<T, S>
impl<T: 'static, S: Storage<T>> CopyValue<T, S>
Sourcepub fn new_maybe_sync(value: T) -> Self
pub fn new_maybe_sync(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 leak_with_caller(value: T, caller: &'static Location<'static>) -> Self
pub fn leak_with_caller(value: T, caller: &'static Location<'static>) -> Self
Create a new CopyValue without an owner. This will leak memory if you don’t manually drop it.
Sourcepub fn point_to(&self, other: Self) -> BorrowResult
pub fn point_to(&self, other: Self) -> BorrowResult
Point to another copy value
Sourcepub fn new_maybe_sync_in_scope(value: T, scope: ScopeId) -> Self
pub fn new_maybe_sync_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 new_maybe_sync_in_scope_with_caller(
value: T,
scope: ScopeId,
caller: &'static Location<'static>,
) -> Self
pub fn new_maybe_sync_in_scope_with_caller( value: T, scope: ScopeId, caller: &'static Location<'static>, ) -> Self
Create a new CopyValue with a custom caller. The value will be stored in the given scope. When the specified scope is dropped, the value will be dropped.
Sourcepub fn manually_drop(&self)
pub fn manually_drop(&self)
Manually drop the value in the CopyValue, invalidating the value in the process.
Sourcepub fn origin_scope(&self) -> ScopeId
pub fn origin_scope(&self) -> ScopeId
Get the scope this value was created in.
Sourcepub fn id(&self) -> GenerationalBoxId
pub fn id(&self) -> GenerationalBoxId
Get the generational id of the value.
Sourcepub fn value(&self) -> GenerationalBox<T, S>
pub fn value(&self) -> GenerationalBox<T, S>
Get the underlying GenerationalBox
value.
Trait Implementations§
Source§impl<T: Add<Output = T> + Copy + 'static, S: Storage<T>> AddAssign<T> for CopyValue<T, S>
impl<T: Add<Output = T> + Copy + 'static, S: Storage<T>> AddAssign<T> for CopyValue<T, S>
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, S: Storage<T>> DivAssign<T> for CopyValue<T, S>
impl<T: Div<Output = T> + Copy + 'static, S: Storage<T>> DivAssign<T> for CopyValue<T, S>
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, S: Storage<T>> MulAssign<T> for CopyValue<T, S>
impl<T: Mul<Output = T> + Copy + 'static, S: Storage<T>> MulAssign<T> for CopyValue<T, S>
Source§fn mul_assign(&mut self, rhs: T)
fn mul_assign(&mut self, rhs: T)
*=
operation. Read moreSource§impl<T: 'static, S: Storage<T>> Readable for CopyValue<T, S>
impl<T: 'static, S: Storage<T>> Readable for CopyValue<T, S>
Source§fn try_read_unchecked(&self) -> Result<ReadableRef<'static, Self>, BorrowError>
fn try_read_unchecked(&self) -> Result<ReadableRef<'static, Self>, BorrowError>
Source§fn try_peek_unchecked(&self) -> BorrowResult<ReadableRef<'static, Self>>
fn try_peek_unchecked(&self) -> BorrowResult<ReadableRef<'static, Self>>
Source§fn map<O>(
self,
f: impl Fn(&Self::Target) -> &O + 'static,
) -> MappedSignal<O, Self::Storage>
fn map<O>( self, f: impl Fn(&Self::Target) -> &O + 'static, ) -> MappedSignal<O, Self::Storage>
Source§fn read(&self) -> ReadableRef<'_, Self>
fn read(&self) -> ReadableRef<'_, Self>
Source§fn try_read(&self) -> Result<ReadableRef<'_, Self>, BorrowError>
fn try_read(&self) -> Result<ReadableRef<'_, Self>, BorrowError>
Source§fn read_unchecked(&self) -> ReadableRef<'static, Self>
fn read_unchecked(&self) -> ReadableRef<'static, Self>
Source§fn peek(&self) -> ReadableRef<'_, Self>
fn peek(&self) -> ReadableRef<'_, Self>
Source§fn try_peek(&self) -> Result<ReadableRef<'_, Self>, BorrowError>
fn try_peek(&self) -> Result<ReadableRef<'_, Self>, BorrowError>
Source§fn peek_unchecked(&self) -> ReadableRef<'static, Self>
fn peek_unchecked(&self) -> ReadableRef<'static, Self>
Source§fn cloned(&self) -> Self::Target
fn cloned(&self) -> Self::Target
Source§fn with<O>(&self, f: impl FnOnce(&Self::Target) -> O) -> O
fn with<O>(&self, f: impl FnOnce(&Self::Target) -> O) -> O
Source§impl<T: Sub<Output = T> + Copy + 'static, S: Storage<T>> SubAssign<T> for CopyValue<T, S>
impl<T: Sub<Output = T> + Copy + 'static, S: Storage<T>> SubAssign<T> for CopyValue<T, S>
Source§fn sub_assign(&mut self, rhs: T)
fn sub_assign(&mut self, rhs: T)
-=
operation. Read more