Trait freya::prelude::Storage

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>

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>

Try to write the value. Returns None if the value is no longer valid.

fn set(&'static self, value: Data)

Set the value

fn take(&'static self) -> Option<Data>

Take the value out of the storage. This will return the value if the value was taken.

Object Safety§

This trait is not object safe.

Implementors§

§

impl<T> Storage<T> for SyncStorage
where T: Sync + Send + 'static,

§

impl<T> Storage<T> for UnsyncStorage
where T: 'static,