[go: up one dir, main page]

Format

Trait Format 

Source
pub trait Format: Debug {
    // Required method
    fn deserialize<T, S>(body: S) -> Result<T, Error>
       where T: DeserializeOwned,
             S: AsRef<[u8]>;
}
Expand description

A trait used to indicate the serialization format used for a response body.

The Response type uses this trait in parameter F to determine how to deserialize the body in to the model T when using Response::into_body. This allows the client library to define the format for each client method so callers can deserialize the model T without having to know or specify the format.

Required Methods§

Source

fn deserialize<T, S>(body: S) -> Result<T, Error>
where T: DeserializeOwned, S: AsRef<[u8]>,

Deserialize body into model T.

§Arguments
  • body - The body to deserialize.
§Returns
  • A Result containing the deserialized model T.

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§

Source§

impl Format for JsonFormat

Available on crate feature json only.
Source§

impl Format for NoFormat

Source§

impl Format for XmlFormat

Available on crate feature xml only.