Struct ContextBuilder

struct ContextBuilder<'a> { ... }

A Builder used to construct a Context instance with support for LocalWaker.

Examples

#![feature(local_waker)]
use std::task::{ContextBuilder, LocalWaker, Waker, Poll};
use std::future::Future;

let local_waker = LocalWaker::noop();
let waker = Waker::noop();

let mut cx = ContextBuilder::from_waker(&waker)
    .local_waker(&local_waker)
    .build();

let mut future = std::pin::pin!(async { 20 });
let poll = future.as_mut().poll(&mut cx);
assert_eq!(poll, Poll::Ready(20));

Implementations

impl<'a> ContextBuilder<'a>

const fn from_waker(waker: &'a Waker) -> Self

Creates a ContextBuilder from a Waker.

const fn from(cx: &'a mut Context<'_>) -> Self

Creates a ContextBuilder from an existing Context.

const fn waker(self: Self, waker: &'a Waker) -> Self

Sets the value for the waker on Context.

const fn local_waker(self: Self, local_waker: &'a LocalWaker) -> Self

Sets the value for the local waker on Context.

const fn ext(self: Self, data: &'a mut dyn Any) -> Self

Sets the value for the extension data on Context.

const fn build(self: Self) -> Context<'a>

Builds the Context.

impl<'a> Debug for ContextBuilder<'a>

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

impl<'a> Freeze for ContextBuilder<'a>

impl<'a> RefUnwindSafe for ContextBuilder<'a>

impl<'a> Send for ContextBuilder<'a>

impl<'a> Sync for ContextBuilder<'a>

impl<'a> Unpin for ContextBuilder<'a>

impl<'a> UnsafeUnpin for ContextBuilder<'a>

impl<'a> UnwindSafe for ContextBuilder<'a>

impl<T> Any for ContextBuilder<'a>

fn type_id(self: &Self) -> TypeId

impl<T> Borrow for ContextBuilder<'a>

fn borrow(self: &Self) -> &T

impl<T> BorrowMut for ContextBuilder<'a>

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

impl<T> From for ContextBuilder<'a>

fn from(t: T) -> T

Returns the argument unchanged.

impl<T, U> Into for ContextBuilder<'a>

fn into(self: 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 for ContextBuilder<'a>

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

impl<T, U> TryInto for ContextBuilder<'a>

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