# actix_web::actix::actix::Handler - Rust
API documentation for the Rust `Handler` trait in crate `actix_web`.
Keywords: rust, rustlang, rust-lang, Handler

# [−] Trait actix_web::actix::actix::Handler

    pub trait Handler<M>: Actor + Actor where
        M: Message, {
        type Result: MessageResponse<Self, M>;
        fn handle(&mut self, msg: M, ctx: &mut Self::Context) -> Self::Result;
    }

Message handler

`Handler` implementation is a general way how to handle incoming messages, streams, futures.

`M` is a message which can be handled by the actor.

## Associated Types

### `type Result: MessageResponse<Self, M>`

The type of value that this handle will return

## Required Methods

### `fn handle(&mut self, msg: M, ctx: &mut Self::Context) -> Self::Result`

Method is called for every message received by this Actor

## Implementations on Foreign Types

###

`impl Handler<PauseServer> for Server`

#### `type Result = ()`

####

`fn handle(&mut self, PauseServer, &mut Context<Server>)` |

###

`impl Handler<ResumeServer> for Server`

#### `type Result = ()`

####

`fn handle(&mut self, ResumeServer, &mut Context<Server>)` |

###

`impl Handler<StopServer> for Server`

#### `type Result = Response<(), ()>`

####

`fn handle( &mut self, msg: StopServer, ctx: &mut Context<Server> ) -> <Server as Handler<StopServer>>::Result` |

###

`impl Handler<Signal> for Server`

Signals support Handle `SIGINT`, `SIGTERM`, `SIGQUIT` signals and stop actix system message to `System` actor.

#### `type Result = ()`

####

`fn handle(&mut self, msg: Signal, ctx: &mut Context<Server>)` |

## Implementors

###

`impl Handler<Connect> for Resolver`

#### `type Result = Box<ActorFuture<Actor = Resolver, Item = TcpStream, Error = ResolverError> + 'static>`

####

`fn handle( &mut self, msg: Connect, &mut <Resolver as Actor>::Context ) -> <Resolver as Handler<Connect>>::Result` |

###

`impl Handler<ConnectAddr> for Resolver`

#### `type Result = Box<ActorFuture<Actor = Resolver, Item = TcpStream, Error = ResolverError> + 'static>`

####

`fn handle( &mut self, msg: ConnectAddr, &mut <Resolver as Actor>::Context ) -> <Resolver as Handler<ConnectAddr>>::Result` |

###

`impl Handler<Resolve> for Resolver`

#### `type Result = Box<ActorFuture<Actor = Resolver, Item = VecDeque<SocketAddr>, Error = ResolverError> + 'static>`

####

`fn handle( &mut self, msg: Resolve, &mut <Resolver as Actor>::Context ) -> <Resolver as Handler<Resolve>>::Result` |

###

`impl Handler<Signal> for DefaultSignalsHandler`

Handle `SIGINT`, `SIGTERM`, `SIGQUIT` signals and send `SystemExit(0)` message to `System` actor.

#### `type Result = ()`

####

`fn handle( &mut self, msg: Signal, &mut <DefaultSignalsHandler as Actor>::Context )` |

###

`impl Handler<Subscribe> for ProcessSignals`

Add subscriber for signals

#### `type Result = ()`

####

`fn handle(&mut self, msg: Subscribe, &mut <ProcessSignals as Actor>::Context)` |

###

`impl Handler<StopArbiter> for Arbiter`

#### `type Result = ()`

####

`fn handle(&mut self, msg: StopArbiter, &mut Context<Arbiter>)` |

###

`impl Handler<Connect> for ClientConnector`

[src]

#### `type Result = ActorResponse<ClientConnector, Connection, ClientConnectorError>`

####

`fn handle(&mut self, msg: Connect, ctx: &mut Self::Context) -> Self::Result`

[src]

###

`impl Handler<Pause> for ClientConnector`

[src]

#### `type Result = ()`

####

`fn handle(&mut self, msg: Pause, _: &mut Self::Context)`

[src]

###

`impl Handler<Resume> for ClientConnector`

[src]

#### `type Result = ()`

####

`fn handle(&mut self, _: Resume, _: &mut Self::Context)`

[src]

###

`impl<A> Handler<StartActor<A>> for Arbiter where A: Actor<Context = Context<A>>,`

#### `type Result = Addr<A>`

####

`fn handle(&mut self, msg: StartActor<A>, &mut Context<Arbiter>) -> Addr<A>` |

###

`impl<I, E> Handler<Execute<I, E>> for Arbiter where E: Send, I: Send,`

#### `type Result = Result<I, E>`

####

`fn handle(&mut self, msg: Execute<I, E>, &mut Context<Arbiter>) -> Result<I, E>` |

###

`impl<M, T> Handler<M> for Mocker<T> where M: 'static + Message, T: 'static, <M as Message>::Result: MessageResponse<Mocker<T>, M>,`

#### `type Result = <M as Message>::Result`

####

`fn handle( &mut self, msg: M, ctx: &mut <Mocker<T> as Actor>::Context ) -> <M as Message>::Result` |

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