Skip to main content

MaybeFuture

Trait MaybeFuture 

Source
pub trait MaybeFuture: IntoFuture + Send
where Self::IntoFuture: Send,
{ // Required method fn wait(self) -> Self::Output; // Provided methods fn map<T, R>(self, f: T) -> Map<Self, T> where T: FnOnce(Self::Output) -> R + Unpin + Send, Self: Sized { ... } fn map_ok<C, T, U, E>(self, c: C) -> impl MaybeFuture where Self: MaybeFuture<Output = Result<T, E>> + Sized, C: FnOnce(T) -> U + Unpin + Send { ... } fn map_err<C, T, E, F>(self, c: C) -> impl MaybeFuture where Self: MaybeFuture<Output = Result<T, E>> + Sized, C: FnOnce(E) -> F + Unpin + Send { ... } }
Expand description

IO that may be performed synchronously or asynchronously.

A MaybeFuture can be run asynchronously with .await, or run synchronously (blocking the current thread) with .wait().

Required Methods§

Source

fn wait(self) -> Self::Output

Block waiting for the action to complete

Provided Methods§

Source

fn map<T, R>(self, f: T) -> Map<Self, T>
where T: FnOnce(Self::Output) -> R + Unpin + Send, Self: Sized,

Apply a function to the output.

Source

fn map_ok<C, T, U, E>(self, c: C) -> impl MaybeFuture
where Self: MaybeFuture<Output = Result<T, E>> + Sized, C: FnOnce(T) -> U + Unpin + Send,

Maps the output’s success value to a different value.

Source

fn map_err<C, T, E, F>(self, c: C) -> impl MaybeFuture
where Self: MaybeFuture<Output = Result<T, E>> + Sized, C: FnOnce(E) -> F + Unpin + Send,

Maps the output’s error value to a different value.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§