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
.