Struct crs_bind::rtos::Promise [−][src]
Represents an ongoing operation which produces a result.
Implementations
impl<T: 'static> Promise<T>[src]
pub fn new() -> (Self, impl FnOnce(T))[src]
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, } );
pub fn done(&self) -> impl Selectable<&T> + '_[src]
A Selectable event which occurs when the promise is resolved.
impl<T: Send + Sync + 'static> Promise<T>[src]
pub fn spawn(f: impl FnOnce() -> T + Send + 'static) -> Self[src]
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().
pub fn try_spawn(f: impl FnOnce() -> T + Send + 'static) -> Result<Self, Error>[src]
Spawns a task to run the given function and returns a Promise that
resolves with the result when it returns.
pub fn then<U: Send + Sync + 'static>(
&self,
f: impl FnOnce(&T) -> U + Send + 'static
) -> Promise<U>[src]
&self,
f: impl FnOnce(&T) -> U + Send + 'static
) -> Promise<U>
Spawns a new promise which, upon the completion of self, runs f.
pub fn then_or<U: Send + Sync + 'static>(
&self,
ctx: Context,
default: U,
f: impl FnOnce(&T) -> U + Send + 'static
) -> Promise<U>[src]
&self,
ctx: Context,
default: U,
f: impl FnOnce(&T) -> U + Send + 'static
) -> Promise<U>
Spawns a new promise which, upon the completion of self, runs f. If
ctx is cancelled before self completes, the result is default.
pub fn then_some<U: Send + Sync + 'static>(
&self,
ctx: Context,
f: impl FnOnce(&T) -> U + Send + 'static
) -> Promise<Option<U>>[src]
&self,
ctx: Context,
f: impl FnOnce(&T) -> U + Send + 'static
) -> Promise<Option<U>>
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
impl<T: 'static> Clone for Promise<T>[src]
fn clone(&self) -> Self[src]
pub fn clone_from(&mut self, source: &Self)1.0.0[src]
Auto Trait Implementations
impl<T> Send for Promise<T> where
T: Send + Sync,
T: Send + Sync,
impl<T> Sync for Promise<T> where
T: Send + Sync,
T: Send + Sync,
impl<T> Unpin for Promise<T>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T[src]
impl<T> From<T> for T[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone, [src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T[src]
pub fn clone_into(&self, target: &mut T)[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,