[][src]Trait tsukuyomi::output::Responder

pub trait Responder {
    type Upgrade: Upgrade;
    type Error: Into<Error>;
    type Respond: Respond<Upgrade = Self::Upgrade, Error = Self::Error>;
    fn respond(self) -> Self::Respond;
}

A trait that abstracts the "reply" to the client.

Derivation

The custom derive Responder is provided for reduce boilerplates around trait implementations.

The macro has a parameter #[response(preset = "..")], which specifies the path to a type that implements a trait Preset:

use serde::Serialize;

#[derive(Debug, Serialize, Responder)]
#[response(preset = "Json")]
struct Post {
    title: String,
    text: String,
}

You can specify the additional trait bounds to type parameters by using the parameter #[response(bound = "..")]:

#[derive(Debug, Responder)]
#[response(
    preset = "Json",
    bound = "T: Serialize",
    bound = "U: Serialize",
)]
struct CustomValue<T, U> {
    t: T,
    u: U,
}

Associated Types

type Upgrade: Upgrade

The type of asynchronous object to be ran after upgrading the protocol.

type Error: Into<Error>

The error type that will be thrown by this responder.

type Respond: Respond<Upgrade = Self::Upgrade, Error = Self::Error>

The asynchronous task converted from this responder.

Loading content...

Required methods

fn respond(self) -> Self::Respond

Converts itself into a Respond.

Loading content...

Implementors

impl<F, T, E> Responder for Oneshot<F> where
    F: FnOnce(&mut Input) -> Result<T, E>,
    T: IntoResponse,
    E: Into<Error>, 
[src]

type Upgrade = NeverUpgrade

type Error = E

type Respond = OneshotRespond<F>

impl<L, R> Responder for Either<L, R> where
    L: Responder,
    R: Responder
[src]

type Upgrade = Either<L::Upgrade, R::Upgrade>

type Error = Error

type Respond = EitherRespond<L::Respond, R::Respond>

impl<P> Responder for NamedFile<P> where
    P: AsRef<Path> + Send + 'static, 
[src]

type Upgrade = NeverUpgrade

type Error = Error

type Respond = OpenNamedFile<P>

impl<R> Responder for ResponderFn<R> where
    R: Respond
[src]

type Upgrade = R::Upgrade

type Error = R::Error

type Respond = R

impl<T> Responder for T where
    T: IntoResponse
[src]

a branket impl of Responder for IntoResponses.

type Upgrade = NeverUpgrade

type Error = Never

type Respond = IntoResponseRespond<T>

impl<T, P> Responder for Rendered<T, P> where
    P: Preset<T>, 
[src]

type Upgrade = P::Upgrade

type Error = P::Error

type Respond = P::Respond

Loading content...