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

# [−] [src] Trait actix_web::Responder

    pub trait Responder {
        type Item: Into<AsyncResult<HttpResponse>>;
        type Error: Into<Error>;
        fn respond_to<S: 'static>(
            self,
            req: &HttpRequest<S>
        ) -> Result<Self::Item, Self::Error>;
    }

Trait implemented by types that generate responses for clients.

Types that implement this trait can be used as the return type of a handler.

## Associated Types

### `type Item: Into<AsyncResult<HttpResponse>>`

The associated item which can be returned.

### `type Error: Into<Error>`

The associated error which can be returned.

## Required Methods

### `fn respond_to<S: 'static>(
self,
req: &HttpRequest<S>
) -> Result<Self::Item, Self::Error>`

Convert itself to `AsyncResult` or `Error`.

## Implementations on Foreign Types

###

`impl<T> Responder for Option<T> where T: Responder,`

[src]

#### `type Item = AsyncResult<HttpResponse>`

#### `type Error = Error`

####

`fn respond_to<S: 'static>( self, req: &HttpRequest<S> ) -> Result<AsyncResult<HttpResponse>, Error>`

[src]

###

`impl<T: Responder, E: Into<Error>> Responder for Result<T, E>`

[src]

#### `type Item = <T as Responder>::Item`

#### `type Error = Error`

####

`fn respond_to<S: 'static>( self, req: &HttpRequest<S> ) -> Result<Self::Item, Error>`

[src]

###

`impl<I, E> Responder for Box<Future<Item = I, Error = E>> where I: Responder + 'static, E: Into<Error> + 'static,`

[src]

#### `type Item = AsyncResult<HttpResponse>`

#### `type Error = Error`

####

`fn respond_to<S: 'static>( self, req: &HttpRequest<S> ) -> Result<AsyncResult<HttpResponse>, Error>`

[src]

###

`impl Responder for &'static str`

[src]

#### `type Item = HttpResponse`

#### `type Error = Error`

####

`fn respond_to<S>(self, req: &HttpRequest<S>) -> Result<HttpResponse, Error>`

[src]

###

`impl Responder for &'static [u8]`

[src]

#### `type Item = HttpResponse`

#### `type Error = Error`

####

`fn respond_to<S>(self, req: &HttpRequest<S>) -> Result<HttpResponse, Error>`

[src]

###

`impl Responder for String`

[src]

#### `type Item = HttpResponse`

#### `type Error = Error`

####

`fn respond_to<S>(self, req: &HttpRequest<S>) -> Result<HttpResponse, Error>`

[src]

###

`impl<'a> Responder for &'a String`

[src]

#### `type Item = HttpResponse`

#### `type Error = Error`

####

`fn respond_to<S>(self, req: &HttpRequest<S>) -> Result<HttpResponse, Error>`

[src]

###

`impl Responder for Bytes`

[src]

#### `type Item = HttpResponse`

#### `type Error = Error`

####

`fn respond_to<S>(self, req: &HttpRequest<S>) -> Result<HttpResponse, Error>`

[src]

###

`impl Responder for BytesMut`

[src]

#### `type Item = HttpResponse`

#### `type Error = Error`

####

`fn respond_to<S>(self, req: &HttpRequest<S>) -> Result<HttpResponse, Error>`

[src]

## Implementors

###

`impl Responder for Binary`

[src]

#### `type Item = HttpResponse`

#### `type Error = Error`

####

`fn respond_to<S>(self, req: &HttpRequest<S>) -> Result<HttpResponse, Error>`

[src]

###

`impl Responder for AsyncResult<HttpResponse>`

[src]

#### `type Item = AsyncResult<HttpResponse>`

#### `type Error = Error`

####

`fn respond_to<S>( self, _: &HttpRequest<S> ) -> Result<AsyncResult<HttpResponse>, Error>`

[src]

###

`impl Responder for HttpResponseBuilder`

[src]

#### `type Item = HttpResponse`

#### `type Error = Error`

####

`fn respond_to<S>(self, _: &HttpRequest<S>) -> Result<HttpResponse, Error>`

[src]

###

`impl Responder for HttpResponse`

[src]

#### `type Item = AsyncResult<HttpResponse>`

#### `type Error = Error`

####

`fn respond_to<S>( self, _: &HttpRequest<S> ) -> Result<AsyncResult<HttpResponse>, Error>`

[src]

###

`impl<A, B> Responder for Either<A, B> where A: Responder, B: Responder,`

[src]

#### `type Item = AsyncResult<HttpResponse>`

#### `type Error = Error`

####

`fn respond_to<S: 'static>( self, req: &HttpRequest<S> ) -> Result<AsyncResult<HttpResponse>, Error>`

[src]

###

`impl<C: StaticFileConfig> Responder for NamedFile<C>`

[src]

#### `type Item = HttpResponse`

#### `type Error = Error`

####

`fn respond_to<S>(self, req: &HttpRequest<S>) -> Result<HttpResponse, Error>`

[src]

###

`impl<T> Responder for InternalError<T> where T: Send + Sync + Debug + Display + 'static,`

[src]

#### `type Item = HttpResponse`

#### `type Error = Error`

####

`fn respond_to<S>(self, _: &HttpRequest<S>) -> Result<HttpResponse, Error>`

[src]

###

`impl<T: Serialize> Responder for Json<T>`

[src]

#### `type Item = HttpResponse`

#### `type Error = Error`

####

`fn respond_to<S>(self, req: &HttpRequest<S>) -> Result<HttpResponse, Error>`

[src]

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