Trait IntoCxxAsyncFuture

Source
pub trait IntoCxxAsyncFuture: Sized {
    type Output;

    // Required method
    fn fallible<Fut>(future: Fut) -> Self
       where Fut: Future<Output = CxxAsyncResult<Self::Output>> + Send + 'static;

    // Provided method
    fn infallible<Fut>(future: Fut) -> Self
       where Fut: Future<Output = Self::Output> + Send + 'static { ... }
}
Expand description

Wraps an arbitrary Rust Future in a boxed cxx-async future so that it can be returned to C++.

You should not need to implement this manually; it’s automatically implemented by the bridge macro.

Required Associated Types§

Source

type Output

The type of the value yielded by the future.

Required Methods§

Source

fn fallible<Fut>(future: Fut) -> Self
where Fut: Future<Output = CxxAsyncResult<Self::Output>> + Send + 'static,

Wraps a Rust Future that returns the output type, wrapped in a CxxAsyncResult.

Use this when you have error values that you want to turn into exceptions on the C++ side.

Provided Methods§

Source

fn infallible<Fut>(future: Fut) -> Self
where Fut: Future<Output = Self::Output> + Send + 'static,

Wraps a Rust Future that directly returns the output type.

Use this when you aren’t interested in propagating errors to C++ as exceptions.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§