Skip to main content

Deferred

Struct Deferred 

Source
pub struct Deferred<A, E> { /* private fields */ }
Expand description

Shared one-shot cell completed with an Exit value.

Implementations§

Source§

impl<A, E> Deferred<A, E>
where A: Clone + Send + Sync + 'static, E: Clone + Send + Sync + 'static,

Source

pub fn make() -> Effect<Deferred<A, E>, Never, ()>

Create an incomplete deferred (watch value starts at None).

Source

pub fn wait(&self) -> Effect<A, Cause<E>, ()>

Suspend until a completion is stored, then return success or the failure Cause.

The error channel is Cause<E> so interrupt / die / structured failures surface faithfully.

Source

pub fn wait_future( &self, ) -> impl Future<Output = Result<A, Cause<E>>> + Send + 'static
where A: Clone + Send + Sync + 'static, E: Clone + Send + Sync + 'static,

Like Self::wait, but returns a Send future for use inside tokio::spawn and other multi-thread executors (the boxed Effect future from Effect::run is not Send).

Source

pub fn try_succeed(&self, value: A) -> bool
where A: Clone,

Try to complete with success (non-blocking). Returns whether this was the first completion.

Source

pub fn try_fail_cause(&self, cause: Cause<E>) -> bool
where E: Clone,

Try to complete with a failure Cause (non-blocking).

Source

pub fn poll(&self) -> Effect<Option<Exit<A, E>>, Never, ()>

Non-blocking read of the current exit, if any.

Source

pub fn is_done(&self) -> Effect<bool, Never, ()>

Returns whether this deferred has been completed (watch value is Some).

Source

pub fn succeed(&self, value: A) -> Effect<bool, Never, ()>

Complete with success. Returns true if this was the first completion.

Source

pub fn fail(&self, error: E) -> Effect<bool, Never, ()>

Complete with Exit::fail. Returns true if this was the first completion.

Source

pub fn fail_cause(&self, cause: Cause<E>) -> Effect<bool, Never, ()>

Complete with an arbitrary Cause. Returns true if this was the first completion.

Source

pub fn interrupt(&self) -> Effect<bool, Never, ()>

Complete with Exit::interrupt. Returns true if this was the first completion.

Source

pub fn complete<R>(&self, eff: Effect<A, E, R>) -> Effect<bool, E, R>

Run eff; on success, complete with Exit::succeed. Returns whether this was the first completion. Effect errors from eff are returned as Err without completing the deferred.

Source

pub fn unsafe_done(&self, exit: Exit<A, E>) -> Effect<(), Never, ()>

Force the stored exit, overwriting any prior value (use sparingly).

Trait Implementations§

Source§

impl<A: Clone, E: Clone> Clone for Deferred<A, E>

Source§

fn clone(&self) -> Deferred<A, E>

Returns a duplicate 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<A: Debug, E: Debug> Debug for Deferred<A, E>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<A, E> Freeze for Deferred<A, E>

§

impl<A, E> RefUnwindSafe for Deferred<A, E>

§

impl<A, E> Send for Deferred<A, E>
where A: Send + Sync, E: Send + Sync,

§

impl<A, E> Sync for Deferred<A, E>
where A: Send + Sync, E: Send + Sync,

§

impl<A, E> Unpin for Deferred<A, E>

§

impl<A, E> UnsafeUnpin for Deferred<A, E>

§

impl<A, E> UnwindSafe for Deferred<A, E>

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, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> Pipe for T

Source§

fn pipe<F, R>(self, f: F) -> R
where F: FnOnce(Self) -> R,

Applies f to self (F#-style forward pipe).
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.