pub struct FutureObj<'a, T>(_);
A custom trait object for polling futures, roughly akin to
Box<dyn Future<Output = T> + Send + 'a>
.
This custom trait object was introduced for two reasons:
- Currently it is not possible to take
dyn Trait
by value and
Box<dyn Trait>
is not available in no_std contexts.
- The
Future
trait is currently not object safe: The Future::poll
method makes uses the arbitrary self types feature and traits in which
this feature is used are currently not object safe due to current compiler
limitations. (See tracking issue for arbitrary self types for more
information #44874)
Create a FutureObj
from a custom trait object representation.
impl<'a, T> Unpin for FutureObj<'a, T>
[src]
impl<'a, T> Debug for FutureObj<'a, T>
[src][+]
impl<'a, T> Future for FutureObj<'a, T>
[src][+]
[+] Show hidden undocumented itemstype Output = T
🔬 This is a nightly-only experimental API. (futures_api
)
futures in libcore are unstable
The type of value produced on completion.
fn poll(self: Pin<&mut FutureObj<'a, T>>, cx: &mut Context) -> Poll<T>
[src][+]
🔬 This is a nightly-only experimental API. (futures_api
)
futures in libcore are unstable
Attempt to resolve the future to a final value, registering the current task for wakeup if the value is not yet available. Read more
impl<'a, F> From<Pin<Box<F>>> for FutureObj<'a, ()> where
F: 'a + Send + Future<Output = ()>,
[src][+]
impl<'a, T> From<FutureObj<'a, T>> for LocalFutureObj<'a, T>
[src][+]
impl<'a, F> From<Box<F>> for FutureObj<'a, ()> where
F: 'a + Send + Future<Output = ()>,
[src][+]
impl<'a, T> Send for FutureObj<'a, T>
[src]
impl<T> From for T
[src][+]
impl<T, U> Into for T where
U: From<T>,
[src][+]
impl<T, U> TryFrom for T where
U: Into<T>,
[src][+]
impl<T> Borrow for T where
T: ?Sized,
[src][+]
impl<T> BorrowMut for T where
T: ?Sized,
[src][+]
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src][+]
impl<T> Any for T where
T: 'static + ?Sized,
[src][+]
impl<T> FutureExt for T where
T: Future + ?Sized,
[src][+]
default fn map<U, F>(self, f: F) -> Map<Self, F> where
F: FnOnce(Self::Output) -> U,
[src][+]
Map this future's output to a different type, returning a new future of the resulting type. Read more
default fn then<Fut, F>(self, f: F) -> Then<Self, Fut, F> where
F: FnOnce(Self::Output) -> Fut,
Fut: Future,
[src][+]
Chain on a computation for when a future finished, passing the result of the future to the provided closure f
. Read more
default fn into_stream(self) -> IntoStream<Self>
[src][+]
Convert this future into a single element stream. Read more
default fn flatten(self) -> Flatten<Self> where
Self::Output: Future,
[src][+]
Flatten the execution of this future when the successful result of this future is itself another future. Read more
default fn flatten_stream(self) -> FlattenStream<Self> where
Self::Output: Stream,
[src][+]
Flatten the execution of this future when the successful result of this future is a stream. Read more
default fn fuse(self) -> Fuse<Self>
[src][+]
Fuse a future such that poll
will never again be called once it has completed. This method can be used to turn any Future
into a FusedFuture
. Read more
default fn inspect<F>(self, f: F) -> Inspect<Self, F> where
F: FnOnce(&Self::Output),
[src][+]
Do something with the output of a future before passing it on. Read more
default fn catch_unwind(self) -> CatchUnwind<Self> where
Self: UnwindSafe,
[src][+]
Catches unwinding panics while polling the future. Read more
default fn shared(self) -> Shared<Self> where
Self::Output: Clone,
[src][+]
Create a cloneable handle to this future where all handles will resolve to the same result. Read more
default fn remote_handle(self) -> (Remote<Self>, RemoteHandle<Self::Output>)
[src][+]
Turn this future into a future that yields ()
on completion and sends its output to another future on a separate task. Read more
default fn boxed(self) -> Pin<Box<Self>>
[src][+]
Wrap the future in a Box, pinning it.
default fn unit_error(self) -> UnitError<Self>
[src][+]
Turns a Future
into a TryFuture
with Error = ()
.
default fn poll_unpin(&mut self, cx: &mut Context) -> Poll<Self::Output> where
Self: Unpin,
[src][+]
A convenience for calling Future::poll
on Unpin
future types.
impl<F, T, E> TryFuture for F where
F: Future<Output = Result<T, E>>,
[src][+]
impl<Fut> TryFutureExt for Fut where
Fut: TryFuture,
[src][+]
default fn flatten_sink<Item>(self) -> FlattenSink<Self, Self::Ok> where
Self::Ok: Sink<Item>,
<Self::Ok as Sink<Item>>::SinkError == Self::Error,
[src][+]
Flattens the execution of this future when the successful result of this future is a [Sink
]. Read more
default fn map_ok<T, F>(self, f: F) -> MapOk<Self, F> where
F: FnOnce(Self::Ok) -> T,
[src][+]
Maps this future's success value to a different value. Read more
default fn map_err<E, F>(self, f: F) -> MapErr<Self, F> where
F: FnOnce(Self::Error) -> E,
[src][+]
Maps this future's error value to a different value. Read more
default fn err_into<E>(self) -> ErrInto<Self, E> where
Self::Error: Into<E>,
[src][+]
Maps this future's Error
to a new error type using the Into
trait. Read more
Important traits for AndThen<Fut1, Fut2, F>
impl<Fut1, Fut2, F> Future for AndThen<Fut1, Fut2, F> where
F: FnOnce(<Fut1 as TryFuture>::Ok) -> Fut2,
Fut1: TryFuture,
Fut2: TryFuture<Error = <Fut1 as TryFuture>::Error>, type Output = Result<<Fut2 as TryFuture>::Ok, <Fut2 as TryFuture>::Error>;
default fn and_then<Fut, F>(self, f: F) -> AndThen<Self, Fut, F> where
F: FnOnce(Self::Ok) -> Fut,
Fut: TryFuture<Error = Self::Error>,
[src][+]
Executes another future after this one resolves successfully. The success value is passed to a closure to create this subsequent future. Read more
Important traits for OrElse<Fut1, Fut2, F>
impl<Fut1, Fut2, F> Future for OrElse<Fut1, Fut2, F> where
F: FnOnce(<Fut1 as TryFuture>::Error) -> Fut2,
Fut1: TryFuture,
Fut2: TryFuture<Ok = <Fut1 as TryFuture>::Ok>, type Output = Result<<Fut2 as TryFuture>::Ok, <Fut2 as TryFuture>::Error>;
default fn or_else<Fut, F>(self, f: F) -> OrElse<Self, Fut, F> where
F: FnOnce(Self::Error) -> Fut,
Fut: TryFuture<Ok = Self::Ok>,
[src][+]
Executes another future if this one resolves to an error. The error value is passed to a closure to create this subsequent future. Read more
default fn unwrap_or_else<F>(self, f: F) -> UnwrapOrElse<Self, F> where
F: FnOnce(Self::Error) -> Self::Ok,
[src][+]
Unwraps this future's ouput, producing a future with this future's Ok
type as its Output
type. Read more
default fn compat(self) -> Compat<Self> where
Self: Unpin,
[src][+]
Wraps a [TryFuture
] into a future compatable with libraries using futures 0.1 future definitons. Requires the compat
feature to enable. Read more
default fn into_future(self) -> IntoFuture<Self>
[src][+]
Wraps a [TryFuture
] into a type that implements Future
. Read more