# [−]Struct actix_web::actix::actix::dev::Context

    pub struct Context<A> where
        A: Actor<Context = Context<A>>,  { /* fields omitted */ }

Actor execution context

## Methods

###

`impl<A> Context<A> where A: Actor<Context = Context<A>>,`

####

`pub fn with_receiver(rx: AddressReceiver<A>) -> Context<A>` |

####

`pub fn run(self, act: A) -> Addr<A>` |

####

`pub fn into_future(self, act: A) -> ContextFut<A, Context<A>>` |

####

`pub fn handle(&self) -> SpawnHandle` |

Handle of the running future

SpawnHandle is the handle returned by `AsyncContext::spawn()` method.

####

`pub fn set_mailbox_capacity(&mut self, cap: usize)` |

Set mailbox capacity

By default mailbox capacity is 16 messages.

## Trait Implementations

###

`impl<A> Debug for Context<A> where A: Actor<Context = Context<A>>,`

####

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

Formats the value using the given formatter. Read more

###

`impl<A> ActorContext for Context<A> where A: Actor<Context = Context<A>>,`

####

`fn stop(&mut self)` |

Immediately stop processing incoming messages and switch to a `stopping` state Read more

####

`fn terminate(&mut self)` |

Terminate actor execution

####

`fn state(&self) -> ActorState` |

Actor execution state

###

`impl<A, M> ToEnvelope<A, M> for Context<A> where A: Actor<Context = Context<A>> + Handler<M>, M: Message + Send + 'static, <M as Message>::Result: Send,`

####

`fn pack(msg: M, tx: Option<Sender<<M as Message>::Result>>) -> Envelope<A>` |

Pack message into suitable envelope

###

`impl<A> AsyncContext<A> for Context<A> where A: Actor<Context = Context<A>>,`

####

`fn spawn<F>(&mut self, fut: F) -> SpawnHandle where F: ActorFuture<Item = (), Error = (), Actor = A> + 'static,` |

Spawn async future into context. Returns handle of the item, could be used for cancelling execution. Read more

####

`fn wait<F>(&mut self, fut: F) where F: ActorFuture<Item = (), Error = (), Actor = A> + 'static,` |

Spawn future into the context. Stop processing any of incoming events until this future resolves. Read more

####

`fn waiting(&self) -> bool` |

Check if context is paused (waiting for future completion or stopping)

####

`fn cancel_future(&mut self, handle: SpawnHandle) -> bool` |

Cancel future. handle is a value returned by `spawn` method.

####

`fn address(&self) -> Addr<A>` |

Return `Address` of the context

####

`fn add_stream<S>(&mut self, fut: S) -> SpawnHandle where A: StreamHandler<<S as Stream>::Item, <S as Stream>::Error>, S: Stream + 'static,` |

This method register stream to an actor context and allows to handle `Stream` in similar way as normal actor messages. Read more

####

`fn add_message_stream<S>(&mut self, fut: S) where A: Handler<<S as Stream>::Item>, S: Stream<Error = ()> + 'static, <S as Stream>::Item: Message,` |

This method is similar to `add_stream` but it skips stream errors. Read more

####

`fn notify<M>(&mut self, msg: M) where A: Handler<M>, M: Message + 'static,` |

Send message `msg` to self.

####

`fn notify_later<M>(&mut self, msg: M, after: Duration) -> SpawnHandle where A: Handler<M>, M: Message + 'static,` |

Send message `msg` to self after specified period of time. Returns spawn handle which could be used for cancellation. Notification get cancelled if context's stop method get called. Read more

####

`fn run_later<F>(&mut self, dur: Duration, f: F) -> SpawnHandle where F: FnOnce(&mut A, &mut <A as Actor>::Context) + 'static,` |

Execute closure after specified period of time within same Actor and Context. Execution get cancelled if context's stop method get called. Read more

####

`fn run_interval<F>(&mut self, dur: Duration, f: F) -> SpawnHandle where F: FnMut(&mut A, &mut <A as Actor>::Context) + 'static,` |

Spawns a job to execute the given closure periodically, at a specified fixed interval Read more

###

`impl<A> AsyncContextParts<A> for Context<A> where A: Actor<Context = Context<A>>,`

####

`fn parts(&mut self) -> &mut ContextParts<A>` |

## Auto Trait Implementations

###

`impl<A> !Send for Context<A>`

###

`impl<A> !Sync for Context<A>`

## Blanket Implementations

###

`impl<T> From for T`

[src]

####

`fn from(t: T) -> T`

[src]

Performs the conversion.

###

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

[src]

####

`fn into(self) -> U`

[src]

Performs the conversion.

###

`impl<T, U> TryFrom for T where T: From<U>,`

[src]

#### `type Error = !`

🔬 This is a nightly-only experimental API. (`try_from`)

The type returned in the event of a conversion error.

####

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

[src]

🔬 This is a nightly-only experimental API. (`try_from`)

Performs the conversion.

###

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

[src]

####

`fn borrow(&self) -> &T`

[src]

Immutably borrows from an owned value. Read more

###

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

[src]

####

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

[src]

Mutably borrows from an owned value. Read more

###

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

[src]

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

🔬 This is a nightly-only experimental API. (`try_from`)

The type returned in the event of a conversion error.

####

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

[src]

🔬 This is a nightly-only experimental API. (`try_from`)

Performs the conversion.

###

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

[src]

####

`fn get_type_id(&self) -> TypeId`

[src]

🔬 This is a nightly-only experimental API. (`get_type_id`)

this method will likely be replaced by an associated static

Gets the `TypeId` of `self`. Read more

###

`impl<T> Erased for T`

# 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`)