Trait tower_web::response::Serializer [−][src]
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.
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,
&self,
value: &T,
format: &Self::Format,
context: &SerializerContext
) -> Result<Bytes, Error> where
T: Serialize,
Serialize the value using the specified format.
Implementations on Foreign Types
impl Serializer for ()[src]
impl Serializer for ()impl<T, U> Serializer for (T, U) where
T: Serializer,
U: Serializer, [src]
impl<T, U> Serializer for (T, U) where
T: Serializer,
U: Serializer, Implementors
impl<T> Serializer for DefaultSerializer<T> where
T: Serializer, type Format = Either2<T::Format, Format>;impl Serializer for Handlebars type Format = ();