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> { /* 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>
[src]

Fulfill the associated promise with a value

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

Trait Implementations

impl<T: Send + 'static, E: Send + 'static> Async for Complete<T, E>
[src]

Returns true if expect will succeed.

Returns true if the async value is ready and has failed

Get the underlying value if present

Invokes the given function when the Async instance is ready to be consumed. Read more

Get the underlying value if present, panic otherwise

Invoke the callback with the resolved Async result.

Blocks the thread until the async value is complete and returns the result. Read more

Trigger the computation without waiting for the result

This method returns a future whose completion value depends on the completion value of the original future. Read more

This method returns a future whose completion value depends on the completion value of the original future. Read more

This method returns a future whose completion value depends on the completion value of the original future. Read more

This method returns a future whose completion value depends on the completion value of the original future. Read more

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

A method called when the value goes out of scope. Read more

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

Formats the value using the given formatter.