Trait Encodes

pub trait Encodes<T>: ContentType + FormatType {
    type Error: Display + Debug;

    // Required method
    fn encode(output: &T) -> Result<Bytes, Self::Error>;
}
Expand description

A trait for types that can be encoded into a bytes for a request body.

Required Associated Types§

type Error: Display + Debug

The error type that can be returned if the encoding fails.

Required Methods§

fn encode(output: &T) -> Result<Bytes, Self::Error>

Encodes the given value into a bytes.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

§

impl<CustErr> Encodes<ServerFnError<CustErr>> for ServerFnErrorEncoding
where CustErr: Display,

§

impl<T> Encodes<T> for JsonEncoding
where T: Serialize,