Struct await::examples::promise::Promise
[−]
[src]
pub struct Promise<T> { // some fields omitted }
Used to fulfill a promise (in other words, complete the Future
)
This can only be owned by one thread, but it can be clone
'd to send to other threads.
XXX: this could use mio
for non-"thread"-blocking
TODO: should Promise
be a trait?
Methods
impl<T> Promise<T>
fn set(self, value: T) -> Option<T>
Fullfill a promise
A promise can only be used once
Returns
None
if the promise was delivered.
If the Future
is dropped before the promise is fulfilled, this will return Some(value)
impl<T, E> Promise<Result<T, E>>
fn success(self, value: T) -> Option<T>
Deliver a successful result
Convenience wrapper around self.set
for the Ok()
case
fn fail_with(self, err: E) -> Option<E>
Deliver a failure
Convenience wrapper around self.set
for the Err()
case