Struct eventual::Complete [] [src]

#[must_use = "Futures must be completed or they will panic on access"]
pub struct Complete<T: Send + 'static, E: Send + 'static> {
    // some fields omitted
}

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();

Methods

impl<T: Send + 'static, E: Send + 'static> Complete<T, E>

fn complete(self, val: T)

Fulfill the associated promise with a value

fn fail(self, err: E)

Reject the associated promise with an error. The error will be wrapped in Async::Error::Failed.

fn abort(self)

fn is_ready(&self) -> bool

fn is_err(&self) -> bool

fn ready<F: FnOnce(Complete<T, E>) + Send + 'static>(self, f: F)

fn await(self) -> AsyncResult<Complete<T, E>, ()>

Trait Implementations

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>>

fn is_ready(&self) -> bool

fn is_err(&self) -> bool

fn poll(self) -> Result<AsyncResult<Complete<T, E>, ()>, Complete<T, E>>

fn ready<F: FnOnce(Complete<T, E>) + Send + 'static>(self, f: F) -> Receipt<Complete<T, E>>

fn expect(self) -> AsyncResult<Self::Value, Self::Error>

fn receive<F>(self, f: F) where F: FnOnce(AsyncResult<Self::Value, Self::Error>) + Send + 'static

fn await(self) -> AsyncResult<Self::Value, Self::Error>

fn fire(self)

fn and<U: Async<Error=Self::Error>>(self, next: U) -> Future<U::Value, Self::Error>

fn and_then<F, U: Async<Error=Self::Error>>(self, f: F) -> Future<U::Value, Self::Error> where F: FnOnce(Self::Value) -> U + Send + 'static, U::Value: Send + 'static

fn or<A>(self, alt: A) -> Future<Self::Value, A::Error> where A: Async<Value=Self::Value>

fn or_else<F, A>(self, f: F) -> Future<Self::Value, A::Error> where F: FnOnce(Self::Error) -> A + Send + 'static, A: Async<Value=Self::Value>

impl<T: Send + 'static, E: Send + 'static> Drop for Complete<T, E>

fn drop(&mut self)

impl<T: Send + 'static, E: Send + 'static> Debug for Complete<T, E>

fn fmt(&self, fmt: &mut Formatter) -> Result