pub struct MaybeAsync<T> { /* private fields */ }
Expand description
Represents a result that may be computed synchronously or asynchronously by user code.
Rust does not currently allow async fn in trait methods, so we need
a workaround. There are crates such as async_trait which provide proc_macros
that do this, but they don’t provide an optimization to avoid the heap allocation
if the underlying implementation is synchronous.
This allows us to use async operations in Rust if desired, but just have synchronous callbacks
in the FFI without paying always allocating.
Retrieve the value, which might be available immediately or require awaiting
Construct a new MaybeAsync from an already available result
Construct a new MaybeAsync from a future which yields the value eventually
Immutably borrows from an owned value.
Read more
Mutably borrows from an owned value.
Read more
Returns the argument unchanged.
Instruments this type with the provided
Span, returning an
Instrumented wrapper.
Read more
Calls U::from(self).
That is, this conversion is whatever the implementation of
From<T> for U chooses to do.
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.