pub trait Storage<Data = ()>: AnyStorage + 'static {
// Required methods
fn try_read(
pointer: GenerationalPointer<Self>,
) -> Result<Self::Ref<'static, Data>, BorrowError>;
fn try_write(
pointer: GenerationalPointer<Self>,
) -> Result<Self::Mut<'static, Data>, BorrowMutError>;
fn new(
value: Data,
caller: &'static Location<'static>,
) -> GenerationalPointer<Self>;
fn new_rc(
value: Data,
caller: &'static Location<'static>,
) -> GenerationalPointer<Self>;
fn new_reference(
inner: GenerationalPointer<Self>,
) -> Result<GenerationalPointer<Self>, BorrowError>;
fn change_reference(
pointer: GenerationalPointer<Self>,
rc_pointer: GenerationalPointer<Self>,
) -> Result<(), BorrowError>;
}
Expand description
A trait for a storage backing type. (RefCell, RwLock, etc.)
Required Methods§
sourcefn try_read(
pointer: GenerationalPointer<Self>,
) -> Result<Self::Ref<'static, Data>, BorrowError>
fn try_read( pointer: GenerationalPointer<Self>, ) -> Result<Self::Ref<'static, Data>, BorrowError>
Try to read the value. Returns None if the value is no longer valid.
sourcefn try_write(
pointer: GenerationalPointer<Self>,
) -> Result<Self::Mut<'static, Data>, BorrowMutError>
fn try_write( pointer: GenerationalPointer<Self>, ) -> Result<Self::Mut<'static, Data>, BorrowMutError>
Try to write the value. Returns None if the value is no longer valid.
sourcefn new(
value: Data,
caller: &'static Location<'static>,
) -> GenerationalPointer<Self>
fn new( value: Data, caller: &'static Location<'static>, ) -> GenerationalPointer<Self>
Create a new memory location. This will either create a new memory location or recycle an old one.
sourcefn new_rc(
value: Data,
caller: &'static Location<'static>,
) -> GenerationalPointer<Self>
fn new_rc( value: Data, caller: &'static Location<'static>, ) -> GenerationalPointer<Self>
Create a new reference counted memory location. This will either create a new memory location or recycle an old one.
sourcefn new_reference(
inner: GenerationalPointer<Self>,
) -> Result<GenerationalPointer<Self>, BorrowError>
fn new_reference( inner: GenerationalPointer<Self>, ) -> Result<GenerationalPointer<Self>, BorrowError>
Reference another location if the location is valid
This method may return an error if the other box is no longer valid or it is already borrowed mutably.
sourcefn change_reference(
pointer: GenerationalPointer<Self>,
rc_pointer: GenerationalPointer<Self>,
) -> Result<(), BorrowError>
fn change_reference( pointer: GenerationalPointer<Self>, rc_pointer: GenerationalPointer<Self>, ) -> Result<(), BorrowError>
Change the reference a signal is pointing to
This method may return an error if the other box is no longer valid or it is already borrowed mutably.
Object Safety§
This trait is not object safe.