std::task::Context - Rust
Description: API documentation for the Rust `Context` struct in crate `std`.
Keywords: rust, rustlang, rust-lang, Context

# Struct std::task::Context[−][src]

    pub struct Context<'a> { /* fields omitted */ }

🔬 This is a nightly-only experimental API. (`futures_api` #50547)

futures in libcore are unstable

Information about the currently-running task.

Contexts are always tied to the stack, since they are set up specifically when performing a single `poll` step on a task.

## Methods

###

`impl<'a> Context<'a>`

[src]

####

`pub fn new( local_waker: &'a LocalWaker, executor: &'a mut (Executor + 'a) ) -> Context<'a>`

[src]

🔬 This is a nightly-only experimental API. (`futures_api` #50547)

futures in libcore are unstable

Create a new task `Context` with the provided `local_waker`, `waker`, and `executor`.

####

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

[src]

🔬 This is a nightly-only experimental API. (`futures_api` #50547)

futures in libcore are unstable

Get the `LocalWaker` associated with the current task.

####

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

[src]

🔬 This is a nightly-only experimental API. (`futures_api` #50547)

futures in libcore are unstable

Get the `Waker` associated with the current task.

####

`pub fn executor(&mut self) -> &mut Executor`

[src]

🔬 This is a nightly-only experimental API. (`futures_api` #50547)

futures in libcore are unstable

Get the default executor associated with this task.

This method is useful primarily if you want to explicitly handle spawn failures.

####

`pub fn with_waker(&'b mut self, local_waker: &'b LocalWaker) -> Context<'b>`

[src]

🔬 This is a nightly-only experimental API. (`futures_api` #50547)

futures in libcore are unstable

Produce a context like the current one, but using the given waker instead.

This advanced method is primarily used when building "internal schedulers" within a task, where you want to provide some customized wakeup logic.

####

`pub fn with_executor<E>(&'b mut self, executor: &'b mut E) -> Context<'b> where E: Executor,`

[src]

🔬 This is a nightly-only experimental API. (`futures_api` #50547)

futures in libcore are unstable

Produce a context like the current one, but using the given executor instead.

This advanced method is primarily used when building "internal schedulers" within a task.

## Trait Implementations

###

`impl<'a> Debug for Context<'a>`

[src]

####

`fn fmt(&self, f: &mut Formatter) -> Result<(), Error>`

[src]

Formats the value using the given formatter. Read more

## Auto Trait Implementations

###

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

###

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

# Help

## Keyboard Shortcuts

`?`
  Show this help dialog
`S`
  Focus the search field
`↑`
  Move up in search results
`↓`
  Move down in search results
`↹`
  Switch tab
`⏎`
  Go to active search result
`+`
  Expand all sections
`-`
  Collapse all sections

## Search Tricks

Prefix searches with a type followed by a colon (e.g. `fn:`) to restrict the search to a given type.

Accepted types are: `fn`, `mod`, `struct`, `enum`, `trait`, `type`, `macro`, and `const`.

Search functions by type signature (e.g. `vec -> usize` or `* -> vec`)

Search multiple things at once by splitting your query with comma (e.g. `str,u8` or `String,struct:Vec,test`)