Skip to main content

Deferred

Struct Deferred 

Source
pub struct Deferred<T> { /* private fields */ }

Implementations§

Source§

impl<T: Copy> Deferred<T>

Source

pub const fn new() -> Self

Source

pub fn wait(&self) -> impl Future<Output = Option<T>> + Send + '_
where T: Send + Sync,

The code once it is in, fetching it if no fetch is running; None if that fails or no loader is registered.

Source

pub fn wake_on_arrival(&self, waker: Waker)

Source

pub fn get(&self) -> Option<T>

The code, or None while it is still to come; a miss starts a fetch.

Source

pub fn fetching(&self) -> bool

Source

pub fn generation(&self) -> u64

Bumped when the code arrives, so what was made without it is made again.

Source

pub fn defer(&self, load: fn())

How the program fetches the code: load starts the fetch, then calls Self::install or Self::load_failed.

Source

pub fn install(&self, value: T)

Source

pub fn load_failed(&self)

The fetch failed: the next use fetches again.

Trait Implementations§

Source§

impl<T: Copy> Default for Deferred<T>

Source§

fn default() -> Self

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

Auto Trait Implementations§

§

impl<T> !Freeze for Deferred<T>

§

impl<T> Forget for Deferred<T>

§

impl<T> Move for Deferred<T>

§

impl<T> RefUnwindSafe for Deferred<T>

§

impl<T> Send for Deferred<T>
where OnceLock<T>: Send,

§

impl<T> Sync for Deferred<T>
where OnceLock<T>: Sync,

§

impl<T> Unpin for Deferred<T>
where OnceLock<T>: Unpin,

§

impl<T> UnsafeUnpin for Deferred<T>

§

impl<T> UnwindSafe for Deferred<T>
where OnceLock<T>: UnwindSafe,

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.