dioxus_lib::prelude

Trait Storage

source
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§

source

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.

source

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.

source

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.

source

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.

source

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.

source

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.

Implementors§

source§

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

source§

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