Struct FutureObj

pub struct FutureObj<'a, T>(/* private field */);

A custom trait object for polling futures, roughly akin to Box<dyn Future<Output = T> + Send + 'a>.

This custom trait object was introduced as currently it is not possible to take dyn Trait by value and Box<dyn Trait> is not available in no_std contexts.

You should generally not need to use this type outside of no_std or when implementing Spawn, consider using BoxFuture instead.

Implementations

impl<'a, T> FutureObj<'a, T>

fn new<F: UnsafeFutureObj<'a, T> + Send>(f: F) -> Self

Create a FutureObj from a custom trait object representation.

Trait Implementations

impl<'a> From<Box<dyn Future<Output = ()> + Send + 'a>> for FutureObj<'a, ()>

fn from(boxed: Box<dyn Future<Output = ()> + Send + 'a>) -> Self

impl<'a> From<Pin<Box<dyn Future<Output = ()> + Send + 'a>>> for FutureObj<'a, ()>

fn from(boxed: Pin<Box<dyn Future<Output = ()> + Send + 'a>>) -> Self

impl<'a, F: Future<Output = ()> + Send + 'a> From<Box<F>> for FutureObj<'a, ()>

fn from(boxed: Box<F>) -> Self

impl<'a, F: Future<Output = ()> + Send + 'a> From<Pin<Box<F>>> for FutureObj<'a, ()>

fn from(boxed: Pin<Box<F>>) -> Self

impl<T> Debug for FutureObj<'_, T>

fn fmt(&self, f: &mut Formatter<'_>) -> Result

impl<T> Future for FutureObj<'_, T>

type Output = T;
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<T>

impl<T> Send for FutureObj<'_, T>

impl<T> Unpin for FutureObj<'_, T>

Auto Trait Implementations

impl<'a, T> !RefUnwindSafe for FutureObj<'a, T>

impl<'a, T> !Sync for FutureObj<'a, T>

impl<'a, T> !UnwindSafe for FutureObj<'a, T>

impl<'a, T> Freeze for FutureObj<'a, T> where LocalFutureObj<'a, T>: Freeze,

impl<'a, T> UnsafeUnpin for FutureObj<'a, T> where LocalFutureObj<'a, T>: UnsafeUnpin,

Blanket Implementations

impl<F> IntoFuture for FutureObj<'a, T> where F: Future,

type Output = <F as Future>::Output;
type IntoFuture = F;
fn into_future(self) -> <F as IntoFuture>::IntoFuture

impl<T> Any for FutureObj<'a, T> where T: 'static + ?Sized,

fn type_id(&self) -> TypeId

impl<T> Borrow<T> for FutureObj<'a, T> where T: ?Sized,

fn borrow(&self) -> &T

impl<T> BorrowMut<T> for FutureObj<'a, T> where T: ?Sized,

fn borrow_mut(&mut self) -> &mut T

impl<T> From<T> for FutureObj<'a, T>

fn from(t: T) -> T

Returns the argument unchanged.

impl<T, U> Into<U> for FutureObj<'a, T> where U: From<T>,

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

impl<T, U> TryFrom<U> for FutureObj<'a, T> where U: Into<T>,

type Error = never;
fn try_from(value: U) -> Result<T, never>

impl<T, U> TryInto<U> for FutureObj<'a, T> where U: TryFrom<T>,

type Error = <U as TryFrom<T>>::Error;
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>