[][src]Trait tower_web::response::Serializer

pub trait Serializer: Clone + Send + Sync + 'static + Sealed {
    type Format: Clone + Send + Sync + 'static;
    fn lookup(&self, name: &str) -> Option<ContentType<Self::Format>>;
fn serialize<T>(
        &self,
        value: &T,
        format: &Self::Format,
        context: &SerializerContext
    ) -> Result<Bytes, Error>
    where
        T: Serialize
; }

Serialize an HTTP response body

Serializer values use one or more Serde serializers to perform the actual serialization.

The Serializer values are also responsible for mapping content-type values to Serde serializers.

Associated Types

type Format: Clone + Send + Sync + 'static

A token used by Serializer implementations to identify the specific serialization format to use when encoding a value.

Loading content...

Required methods

fn lookup(&self, name: &str) -> Option<ContentType<Self::Format>>

Lookup a serializer and HeaderValue for the given Content-Type string.

fn serialize<T>(
    &self,
    value: &T,
    format: &Self::Format,
    context: &SerializerContext
) -> Result<Bytes, Error> where
    T: Serialize

Serialize the value using the specified format.

Loading content...

Implementations on Foreign Types

impl Serializer for ()[src]

type Format = Void

impl<T, U> Serializer for (T, U) where
    T: Serializer,
    U: Serializer
[src]

type Format = Either2<T::Format, U::Format>

Loading content...

Implementors

impl Serializer for Handlebars[src]

type Format = ()

impl<T> Serializer for DefaultSerializer<T> where
    T: Serializer
[src]

type Format = Either2<T::Format, Format>

Loading content...