pub struct Complete<T: Send + 'static, E: Send + 'static> { /* private fields */ }Expand description
An object that is used to fulfill or reject an associated Future.
use eventual::*;
let (tx, future) = Future::<u32, &'static str>::pair();
future.and_then(|v| {
assert!(v == 1);
Ok(v + v)
}).fire();
tx.complete(1);
let (tx, future) = Future::<u32, &'static str>::pair();
tx.fail("failed");
future.or_else(|err| {
assert!(err == "failed");
Ok::<u32, &'static str>(123)
}).fire();Implementations§
Source§impl<T: Send + 'static, E: Send + 'static> Complete<T, E>
impl<T: Send + 'static, E: Send + 'static> Complete<T, E>
Sourcepub fn fail(self, err: E)
pub fn fail(self, err: E)
Reject the associated promise with an error. The error
will be wrapped in Async::Error::Failed.
pub fn abort(self)
pub fn is_ready(&self) -> bool
pub fn is_err(&self) -> bool
pub fn ready<F: FnOnce(Complete<T, E>) + Send + 'static>(self, f: F)
pub fn await(self) -> AsyncResult<Complete<T, E>, ()>
Trait Implementations§
Source§impl<T: Send + 'static, E: Send + 'static> Async for Complete<T, E>
impl<T: Send + 'static, E: Send + 'static> Async for Complete<T, E>
type Value = Complete<T, E>
type Error = ()
type Cancel = Receipt<Complete<T, E>>
Source§fn poll(self) -> Result<AsyncResult<Complete<T, E>, ()>, Complete<T, E>>
fn poll(self) -> Result<AsyncResult<Complete<T, E>, ()>, Complete<T, E>>
Get the underlying value if present
Source§fn ready<F: FnOnce(Complete<T, E>) + Send + 'static>(
self,
f: F,
) -> Receipt<Complete<T, E>>
fn ready<F: FnOnce(Complete<T, E>) + Send + 'static>( self, f: F, ) -> Receipt<Complete<T, E>>
Invokes the given function when the Async instance is ready to be
consumed.
Source§fn expect(self) -> AsyncResult<Self::Value, Self::Error>
fn expect(self) -> AsyncResult<Self::Value, Self::Error>
Get the underlying value if present, panic otherwise
Source§fn await(self) -> AsyncResult<Self::Value, Self::Error>
fn await(self) -> AsyncResult<Self::Value, Self::Error>
Blocks the thread until the async value is complete and returns the
result.
Source§fn and<U: Async<Error = Self::Error>>(
self,
next: U,
) -> Future<U::Value, Self::Error>
fn and<U: Async<Error = Self::Error>>( self, next: U, ) -> Future<U::Value, Self::Error>
This method returns a future whose completion value depends on the
completion value of the original future. Read more
Source§fn and_then<F, U: Async<Error = Self::Error>>(
self,
f: F,
) -> Future<U::Value, Self::Error>
fn and_then<F, U: Async<Error = Self::Error>>( self, f: F, ) -> Future<U::Value, Self::Error>
This method returns a future whose completion value depends on the
completion value of the original future. Read more
Source§impl<T: Send + 'static, E: Send + 'static> Cancel<Complete<T, E>> for Receipt<Complete<T, E>>
impl<T: Send + 'static, E: Send + 'static> Cancel<Complete<T, E>> for Receipt<Complete<T, E>>
Auto Trait Implementations§
impl<T, E> Freeze for Complete<T, E>
impl<T, E> !RefUnwindSafe for Complete<T, E>
impl<T, E> Send for Complete<T, E>
impl<T, E> !Sync for Complete<T, E>
impl<T, E> Unpin for Complete<T, E>
impl<T, E> !UnwindSafe for Complete<T, 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
Mutably borrows from an owned value. Read more