Skip to main content

RenderAs

Trait RenderAs 

Source
pub trait RenderAs<Format: ContentFormat> {
    // Required method
    fn render(&self) -> Result<(Vec<u8>, &'static str), String>;
}
Expand description

Convert a domain type into bytes for a specific content format.

Implement this trait to teach the negotiation engine how to serialize your type as a particular format.

Blanket implementations are provided for:

  • RenderAs<JsonFormat> for any T: serde::Serialize
  • RenderAs<TextFormat> for any T: Display

Required Methods§

Source

fn render(&self) -> Result<(Vec<u8>, &'static str), String>

Render this value into bytes and its content-type string.

Implementors§