pub trait Storage<Data = ()>: AnyStorage + 'static {
// Required methods
fn try_read(
&'static self,
at: GenerationalRefBorrowInfo,
) -> Result<Self::Ref<'static, Data>, BorrowError>;
fn try_write(
&'static self,
at: GenerationalRefMutBorrowInfo,
) -> Result<Self::Mut<'static, Data>, BorrowMutError>;
fn set(&'static self, value: Data);
fn take(&'static self) -> Option<Data>;
}
Expand description
A trait for a storage backing type. (RefCell, RwLock, etc.)
Required Methods§
fn try_read(
&'static self,
at: GenerationalRefBorrowInfo,
) -> Result<Self::Ref<'static, Data>, BorrowError>
fn try_read( &'static self, at: GenerationalRefBorrowInfo, ) -> Result<Self::Ref<'static, Data>, BorrowError>
Try to read the value. Returns None if the value is no longer valid.
fn try_write(
&'static self,
at: GenerationalRefMutBorrowInfo,
) -> Result<Self::Mut<'static, Data>, BorrowMutError>
fn try_write( &'static self, at: GenerationalRefMutBorrowInfo, ) -> Result<Self::Mut<'static, Data>, BorrowMutError>
Try to write the value. Returns None if the value is no longer valid.
fn set(&'static self, value: Data)
fn set(&'static self, value: Data)
Set the value
Object Safety§
This trait is not object safe.