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>
impl<A, E> Deferred<A, E>
Sourcepub fn make() -> Effect<Deferred<A, E>, Never, ()>
pub fn make() -> Effect<Deferred<A, E>, Never, ()>
Create an incomplete deferred (watch value starts at None).
Sourcepub fn wait_future(
&self,
) -> impl Future<Output = Result<A, Cause<E>>> + Send + 'static
pub fn wait_future( &self, ) -> impl Future<Output = Result<A, Cause<E>>> + Send + '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).
Sourcepub fn try_succeed(&self, value: A) -> boolwhere
A: Clone,
pub fn try_succeed(&self, value: A) -> boolwhere
A: Clone,
Try to complete with success (non-blocking). Returns whether this was the first completion.
Sourcepub fn try_fail_cause(&self, cause: Cause<E>) -> boolwhere
E: Clone,
pub fn try_fail_cause(&self, cause: Cause<E>) -> boolwhere
E: Clone,
Try to complete with a failure Cause (non-blocking).
Sourcepub fn poll(&self) -> Effect<Option<Exit<A, E>>, Never, ()>
pub fn poll(&self) -> Effect<Option<Exit<A, E>>, Never, ()>
Non-blocking read of the current exit, if any.
Sourcepub fn is_done(&self) -> Effect<bool, Never, ()>
pub fn is_done(&self) -> Effect<bool, Never, ()>
Returns whether this deferred has been completed (watch value is Some).
Sourcepub fn succeed(&self, value: A) -> Effect<bool, Never, ()>
pub fn succeed(&self, value: A) -> Effect<bool, Never, ()>
Complete with success. Returns true if this was the first completion.
Sourcepub fn fail(&self, error: E) -> Effect<bool, Never, ()>
pub fn fail(&self, error: E) -> Effect<bool, Never, ()>
Complete with Exit::fail. Returns true if this was the first completion.
Sourcepub fn fail_cause(&self, cause: Cause<E>) -> Effect<bool, Never, ()>
pub fn fail_cause(&self, cause: Cause<E>) -> Effect<bool, Never, ()>
Complete with an arbitrary Cause. Returns true if this was the first completion.
Sourcepub fn interrupt(&self) -> Effect<bool, Never, ()>
pub fn interrupt(&self) -> Effect<bool, Never, ()>
Complete with Exit::interrupt. Returns true if this was the first completion.
Trait Implementations§
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>
impl<A, E> Sync for Deferred<A, E>
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<T> Capability for T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more