Struct Context

1.36.0 ยท Source
pub struct Context<'a> { /* private fields */ }
Expand description

The context of an asynchronous task.

Currently, Context only serves to provide access to a &Waker which can be used to wake the current task.

Implementationsยง

Sourceยง

impl<'a> Context<'a>

1.36.0 (const: 1.82.0) ยท Source

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

Creates a new Context from a &Waker.

1.36.0 (const: 1.82.0) ยท Source

pub const fn waker(&self) -> &'a Waker

Returns a reference to the Waker for the current task.

Source

pub const fn local_waker(&self) -> &'a LocalWaker

๐Ÿ”ฌThis is a nightly-only experimental API. (local_waker #118959)

Returns a reference to the LocalWaker for the current task.

Source

pub const fn ext(&mut self) -> &mut dyn Any

๐Ÿ”ฌThis is a nightly-only experimental API. (context_ext #123392)

Returns a reference to the extension data for the current task.

Trait Implementationsยง

1.36.0 ยท Sourceยง

impl Debug for Context<'_>

Sourceยง

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

Formats the value using the given formatter. Read more

Auto Trait Implementationsยง

ยง

impl<'a> Freeze for Context<'a>

ยง

impl<'a> RefUnwindSafe for Context<'a>

ยง

impl<'a> !Send for Context<'a>

ยง

impl<'a> !Sync for Context<'a>

ยง

impl<'a> Unpin for Context<'a>

ยง

impl<'a> UnwindSafe for Context<'a>

Blanket Implementationsยง

Sourceยง

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

Sourceยง

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Sourceยง

impl<T> Borrow<T> for T
where T: ?Sized,

Sourceยง

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Sourceยง

impl<T> BorrowMut<T> for T
where T: ?Sized,

Sourceยง

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

Mutably borrows from an owned value. Read more
Sourceยง

impl<T> From<T> for T

Sourceยง

fn from(t: T) -> T

Returns the argument unchanged.

Sourceยง

impl<T, U> Into<U> for T
where U: From<T>,

Sourceยง

fn into(self) -> U

Calls U::from(self).

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

Sourceยง

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Sourceยง

type Error = Infallible

The type returned in the event of a conversion error.
Sourceยง

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

Performs the conversion.
Sourceยง

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Sourceยง

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Sourceยง

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

Performs the conversion.