pub struct CopyValue<T, S = UnsyncStorage>where
T: 'static,
S: Storage<T>,{ /* 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> CopyValue<T>where
T: 'static,
impl<T> CopyValue<T>where
T: 'static,
sourcepub fn new(value: T) -> CopyValue<T>
pub fn new(value: T) -> CopyValue<T>
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) -> CopyValue<T>
pub fn new_in_scope(value: T, scope: ScopeId) -> CopyValue<T>
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, S> CopyValue<T, S>where
T: 'static,
S: Storage<T>,
impl<T, S> CopyValue<T, S>where
T: 'static,
S: Storage<T>,
sourcepub fn new_maybe_sync(value: T) -> CopyValue<T, S>
pub fn new_maybe_sync(value: T) -> CopyValue<T, S>
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>,
) -> CopyValue<T, S>
pub fn leak_with_caller( value: T, caller: &'static Location<'static>, ) -> CopyValue<T, S>
Create a new CopyValue without an owner. This will leak memory if you don’t manually drop it.
sourcepub fn point_to(&mut self, other: CopyValue<T, S>) -> Result<(), BorrowError>
pub fn point_to(&mut self, other: CopyValue<T, S>) -> Result<(), BorrowError>
Point to another copy value
sourcepub fn new_maybe_sync_in_scope(value: T, scope: ScopeId) -> CopyValue<T, S>
pub fn new_maybe_sync_in_scope(value: T, scope: ScopeId) -> CopyValue<T, S>
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>,
) -> CopyValue<T, S>
pub fn new_maybe_sync_in_scope_with_caller( value: T, scope: ScopeId, caller: &'static Location<'static>, ) -> CopyValue<T, S>
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, S> AddAssign<T> for CopyValue<T, S>
impl<T, S> 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, S> DivAssign<T> for CopyValue<T, S>
impl<T, S> 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, S> MulAssign<T> for CopyValue<T, S>
impl<T, S> 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, S> Readable for CopyValue<T, S>where
T: 'static,
S: Storage<T>,
impl<T, S> Readable for CopyValue<T, S>where
T: 'static,
S: Storage<T>,
source§fn try_read_unchecked(
&self,
) -> Result<<<CopyValue<T, S> as Readable>::Storage as AnyStorage>::Ref<'static, <CopyValue<T, S> as Readable>::Target>, BorrowError>
fn try_read_unchecked( &self, ) -> Result<<<CopyValue<T, S> as Readable>::Storage as AnyStorage>::Ref<'static, <CopyValue<T, S> as Readable>::Target>, BorrowError>
source§fn try_peek_unchecked(
&self,
) -> Result<<<CopyValue<T, S> as Readable>::Storage as AnyStorage>::Ref<'static, <CopyValue<T, S> as Readable>::Target>, BorrowError>
fn try_peek_unchecked( &self, ) -> Result<<<CopyValue<T, S> as Readable>::Storage as AnyStorage>::Ref<'static, <CopyValue<T, S> as Readable>::Target>, BorrowError>
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) -> <Self::Storage as AnyStorage>::Ref<'_, Self::Target>
fn read(&self) -> <Self::Storage as AnyStorage>::Ref<'_, Self::Target>
source§fn try_read(
&self,
) -> Result<<Self::Storage as AnyStorage>::Ref<'_, Self::Target>, BorrowError>
fn try_read( &self, ) -> Result<<Self::Storage as AnyStorage>::Ref<'_, Self::Target>, BorrowError>
source§fn read_unchecked(
&self,
) -> <Self::Storage as AnyStorage>::Ref<'static, Self::Target>
fn read_unchecked( &self, ) -> <Self::Storage as AnyStorage>::Ref<'static, Self::Target>
source§fn peek(&self) -> <Self::Storage as AnyStorage>::Ref<'_, Self::Target>
fn peek(&self) -> <Self::Storage as AnyStorage>::Ref<'_, Self::Target>
source§fn try_peek(
&self,
) -> Result<<Self::Storage as AnyStorage>::Ref<'_, Self::Target>, BorrowError>
fn try_peek( &self, ) -> Result<<Self::Storage as AnyStorage>::Ref<'_, Self::Target>, BorrowError>
source§fn peek_unchecked(
&self,
) -> <Self::Storage as AnyStorage>::Ref<'static, Self::Target>
fn peek_unchecked( &self, ) -> <Self::Storage as AnyStorage>::Ref<'static, 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, S> SubAssign<T> for CopyValue<T, S>
impl<T, S> SubAssign<T> for CopyValue<T, S>
source§fn sub_assign(&mut self, rhs: T)
fn sub_assign(&mut self, rhs: T)
-=
operation. Read moresource§impl<T, S> Writable for CopyValue<T, S>where
T: 'static,
S: Storage<T>,
impl<T, S> Writable for CopyValue<T, S>where
T: 'static,
S: Storage<T>,
source§fn map_mut<I, U, F>(
mut_: <CopyValue<T, S> as Writable>::Mut<'_, I>,
f: F,
) -> <CopyValue<T, S> as Writable>::Mut<'_, U>
fn map_mut<I, U, F>( mut_: <CopyValue<T, S> as Writable>::Mut<'_, I>, f: F, ) -> <CopyValue<T, S> as Writable>::Mut<'_, U>
source§fn try_map_mut<I, U, F>(
mut_: <CopyValue<T, S> as Writable>::Mut<'_, I>,
f: F,
) -> Option<<CopyValue<T, S> as Writable>::Mut<'_, U>>
fn try_map_mut<I, U, F>( mut_: <CopyValue<T, S> as Writable>::Mut<'_, I>, f: F, ) -> Option<<CopyValue<T, S> as Writable>::Mut<'_, U>>
source§fn downcast_lifetime_mut<'a, 'b, R>(
mut_: <CopyValue<T, S> as Writable>::Mut<'a, R>,
) -> <CopyValue<T, S> as Writable>::Mut<'b, R>where
'a: 'b,
R: 'static + ?Sized,
fn downcast_lifetime_mut<'a, 'b, R>(
mut_: <CopyValue<T, S> as Writable>::Mut<'a, R>,
) -> <CopyValue<T, S> as Writable>::Mut<'b, R>where
'a: 'b,
R: 'static + ?Sized,
source§fn try_write_unchecked(
&self,
) -> Result<<CopyValue<T, S> as Writable>::Mut<'static, <CopyValue<T, S> as Readable>::Target>, BorrowMutError>
fn try_write_unchecked( &self, ) -> Result<<CopyValue<T, S> as Writable>::Mut<'static, <CopyValue<T, S> as Readable>::Target>, BorrowMutError>
source§fn set(&mut self, value: T)
fn set(&mut self, value: T)
source§fn write(&mut self) -> Self::Mut<'_, Self::Target>
fn write(&mut self) -> Self::Mut<'_, Self::Target>
source§fn try_write(&mut self) -> Result<Self::Mut<'_, Self::Target>, BorrowMutError>
fn try_write(&mut self) -> Result<Self::Mut<'_, Self::Target>, BorrowMutError>
source§fn write_unchecked(&self) -> Self::Mut<'static, Self::Target>
fn write_unchecked(&self) -> Self::Mut<'static, Self::Target>
impl<T, S> Copy for CopyValue<T, S>where
S: Storage<T>,
impl<T, S> Eq for CopyValue<T, S>where
T: 'static,
S: Storage<T>,
Auto Trait Implementations§
impl<T, S> Freeze for CopyValue<T, S>
impl<T, S> RefUnwindSafe for CopyValue<T, S>where
T: RefUnwindSafe,
S: RefUnwindSafe,
impl<T, S> Send for CopyValue<T, S>
impl<T, S> Sync for CopyValue<T, S>
impl<T, S> Unpin for CopyValue<T, S>where
T: Unpin,
impl<T, S> UnwindSafe for CopyValue<T, S>where
T: UnwindSafe,
S: RefUnwindSafe,
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)