Struct vex_rt::rtos::Promise

source ·
pub struct Promise<T: 'static = ()>(_);
Expand description

Represents an ongoing operation which produces a result.

Implementations§

Creates a new lightweight promise and an associated resolve function.

Example
let (promise, resolve) = Promise::<i32>::new();
Task::spawn(|| {
    Task::delay(Duration::from_secs(1));
    resolve(10);
})
.unwrap();
println!(
    "n = {}",
    select! {
        n = promise.done() => n,
    }
);

A Selectable event which occurs when the promise is resolved.

Spawns a task to run the given function and returns a Promise that resolves with the result when it returns. Panics on failure; see Promise::try_spawn().

Spawns a task to run the given function and returns a Promise that resolves with the result when it returns.

Spawns a new promise which, upon the completion of self, runs f.

Spawns a new promise which, upon the completion of self, runs f. If ctx is cancelled before self completes, the result is default.

Spawns a new promise which, upon the completion of self, runs f. If ctx is cancelled before self completes, the result is None.

Trait Implementations§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.