dioxus_lib::prelude

Struct Owner

source
pub struct Owner<S = UnsyncStorage>(/* private fields */)
where
    S: AnyStorage + 'static;
Expand description

Owner: Handles dropping generational boxes. The owner acts like a runtime lifetime guard. Any states that you create with an owner will be dropped when that owner is dropped.

Implementations§

source§

impl<S> Owner<S>
where S: AnyStorage,

source

pub fn insert<T>(&self, value: T) -> GenerationalBox<T, S>
where T: 'static, S: Storage<T>,

Insert a value into the store. The value will be dropped when the owner is dropped.

source

pub fn insert_rc<T>(&self, value: T) -> GenerationalBox<T, S>
where T: 'static, S: Storage<T>,

Create a new reference counted box. The box will be dropped when all references are dropped.

source

pub fn insert_rc_with_caller<T>( &self, value: T, caller: &'static Location<'static>, ) -> GenerationalBox<T, S>
where T: 'static, S: Storage<T>,

Insert a value into the store with a specific location blamed for creating the value. The value will be dropped when the owner is dropped.

source

pub fn insert_with_caller<T>( &self, value: T, caller: &'static Location<'static>, ) -> GenerationalBox<T, S>
where T: 'static, S: Storage<T>,

Insert a value into the store with a specific location blamed for creating the value. The value will be dropped when the owner is dropped.

source

pub fn insert_reference<T>( &self, other: GenerationalBox<T, S>, ) -> Result<GenerationalBox<T, S>, BorrowError>
where T: 'static, S: Storage<T>,

Create a new reference to an existing box. The reference will be dropped when the owner is dropped.

This method may return an error if the other box is no longer valid or it is already borrowed mutably.

Trait Implementations§

source§

impl<S> Clone for Owner<S>
where S: AnyStorage,

source§

fn clone(&self) -> Owner<S>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<S> Default for Owner<S>
where S: AnyStorage,

source§

fn default() -> Owner<S>

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<S> Freeze for Owner<S>

§

impl<S = UnsyncStorage> !RefUnwindSafe for Owner<S>

§

impl<S> Send for Owner<S>
where S: Sync,

§

impl<S> Sync for Owner<S>
where S: Sync,

§

impl<S> Unpin for Owner<S>

§

impl<S = UnsyncStorage> !UnwindSafe for Owner<S>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> CloneToUninit for T
where T: Clone,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> InitializeFromFunction<T> for T

source§

fn initialize_from_function(f: fn() -> T) -> T

Create an instance of this type from an initialization function
source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<Ret> SpawnIfAsync<(), Ret> for Ret

source§

fn spawn(self) -> Ret

Spawn the value into the dioxus runtime if it is an async block
source§

impl<T, O> SuperFrom<T> for O
where O: From<T>,

source§

fn super_from(input: T) -> O

Convert from a type to another type.
source§

impl<T, O, M> SuperInto<O, M> for T
where O: SuperFrom<T, M>,

source§

fn super_into(self) -> O

Convert from a type to another type.
source§

impl<T> ToOwned for T
where T: Clone,

source§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

source§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more