Struct kernel::io::Promise [−] [src]

pub struct Promise<T>(_);

A computation that might eventually resolve to a value of type T.

Methods

impl<T: 'static> Promise<T>

fn new(d: Deferred<T>) -> Self

Creates a promise from a kernel Deferred object. The promise is resolved once the deferred is resolved.

fn resolved(value: T) -> Self

Creates a promise from a constant value. The promise is resolved immediately.

fn get(self) -> T

Blocks until the promise is resolved, then returns the value within.

fn try_get(self) -> Result<T, Self>

Attempts to get the value inside the promise.

If the promise is resolved, consumes the promise and returns Some(value). Otherwise, returns Err containing the original promise.

fn then<U, F: FnOnce(T) -> U + 'static>(self, f: F) -> Promise<U>

Returns a new promise that applies a function to the value inside the promise.

impl<T: 'static> Promise<Promise<T>>

fn unwrap(self) -> Promise<T>

Given a promise that resolves to Promise<T>, returns a promise that resolves to T.