dioxus_lib::prelude

Trait AnyStorage

source
pub trait AnyStorage: Default + 'static {
    type Ref<'a, T: 'static + ?Sized>: Deref<Target = T>;
    type Mut<'a, T: 'static + ?Sized>: DerefMut<Target = T>;

    // Required methods
    fn downcast_lifetime_ref<'a, 'b, T>(
        ref_: Self::Ref<'a, T>,
    ) -> Self::Ref<'b, T>
       where 'a: 'b,
             T: 'static + ?Sized;
    fn downcast_lifetime_mut<'a, 'b, T>(
        mut_: Self::Mut<'a, T>,
    ) -> Self::Mut<'b, T>
       where 'a: 'b,
             T: 'static + ?Sized;
    fn try_map_mut<T, U>(
        mut_ref: Self::Mut<'_, T>,
        f: impl FnOnce(&mut T) -> Option<&mut U>,
    ) -> Option<Self::Mut<'_, U>>
       where T: 'static + ?Sized,
             U: 'static + ?Sized;
    fn try_map<T, U>(
        ref_: Self::Ref<'_, T>,
        f: impl FnOnce(&T) -> Option<&U>,
    ) -> Option<Self::Ref<'_, U>>
       where U: 'static + ?Sized,
             T: ?Sized;
    fn data_ptr(&self) -> *const ();
    fn recycle(location: GenerationalPointer<Self>);

    // Provided methods
    fn map_mut<T, U>(
        mut_ref: Self::Mut<'_, T>,
        f: impl FnOnce(&mut T) -> &mut U,
    ) -> Self::Mut<'_, U>
       where T: 'static + ?Sized,
             U: 'static + ?Sized { ... }
    fn map<T, U>(
        ref_: Self::Ref<'_, T>,
        f: impl FnOnce(&T) -> &U,
    ) -> Self::Ref<'_, U>
       where U: 'static + ?Sized,
             T: ?Sized { ... }
    fn owner() -> Owner<Self> { ... }
}
Expand description

A trait for any storage backing type.

Required Associated Types§

source

type Ref<'a, T: 'static + ?Sized>: Deref<Target = T>

The reference this storage type returns.

source

type Mut<'a, T: 'static + ?Sized>: DerefMut<Target = T>

The mutable reference this storage type returns.

Required Methods§

source

fn downcast_lifetime_ref<'a, 'b, T>(ref_: Self::Ref<'a, T>) -> Self::Ref<'b, T>
where 'a: 'b, T: 'static + ?Sized,

Downcast a reference in a Ref to a more specific lifetime

This function enforces the variance of the lifetime parameter 'a in Ref. Rust will typically infer this cast with a concrete type, but it cannot with a generic type.

source

fn downcast_lifetime_mut<'a, 'b, T>(mut_: Self::Mut<'a, T>) -> Self::Mut<'b, T>
where 'a: 'b, T: 'static + ?Sized,

Downcast a mutable reference in a RefMut to a more specific lifetime

This function enforces the variance of the lifetime parameter 'a in Mut. Rust will typically infer this cast with a concrete type, but it cannot with a generic type.

source

fn try_map_mut<T, U>( mut_ref: Self::Mut<'_, T>, f: impl FnOnce(&mut T) -> Option<&mut U>, ) -> Option<Self::Mut<'_, U>>
where T: 'static + ?Sized, U: 'static + ?Sized,

Try to map the mutable ref.

source

fn try_map<T, U>( ref_: Self::Ref<'_, T>, f: impl FnOnce(&T) -> Option<&U>, ) -> Option<Self::Ref<'_, U>>
where U: 'static + ?Sized, T: ?Sized,

Try to map the ref.

source

fn data_ptr(&self) -> *const ()

Get the data pointer. No guarantees are made about the data pointer. It should only be used for debugging.

source

fn recycle(location: GenerationalPointer<Self>)

Recycle a memory location. This will drop the memory location and return it to the runtime.

Provided Methods§

source

fn map_mut<T, U>( mut_ref: Self::Mut<'_, T>, f: impl FnOnce(&mut T) -> &mut U, ) -> Self::Mut<'_, U>
where T: 'static + ?Sized, U: 'static + ?Sized,

Map the mutable ref.

source

fn map<T, U>( ref_: Self::Ref<'_, T>, f: impl FnOnce(&T) -> &U, ) -> Self::Ref<'_, U>
where U: 'static + ?Sized, T: ?Sized,

Map the ref.

source

fn owner() -> Owner<Self>

Create a new owner. The owner will be responsible for dropping all of the generational boxes that it creates.

Object Safety§

This trait is not object safe.

Implementors§