Skip to main content

NegotiateFormats

Trait NegotiateFormats 

Source
pub trait NegotiateFormats<T> {
    // Required methods
    fn supported_types() -> Vec<&'static str>;
    fn negotiate_and_render(
        value: &T,
        accept: Option<&str>,
    ) -> Result<(Vec<u8>, &'static str), String>;
}
Expand description

Select the best format from a tuple of formats based on the Accept header and render the domain value.

Implemented for format tuples of arities 1 through 6 via macro.

Required Methods§

Source

fn supported_types() -> Vec<&'static str>

All supported content types, in preference order.

Source

fn negotiate_and_render( value: &T, accept: Option<&str>, ) -> Result<(Vec<u8>, &'static str), String>

Pick the best format for the given Accept header and render value.

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.

Implementations on Foreign Types§

Source§

impl<T, F1> NegotiateFormats<T> for (F1,)
where F1: ContentFormat, T: RenderAs<F1>,

Source§

fn supported_types() -> Vec<&'static str>

Source§

fn negotiate_and_render( value: &T, _accept: Option<&str>, ) -> Result<(Vec<u8>, &'static str), String>

Source§

impl<T, F1, F2> NegotiateFormats<T> for (F1, F2)
where F1: ContentFormat, F2: ContentFormat, T: RenderAs<F1> + RenderAs<F2>,

Source§

fn supported_types() -> Vec<&'static str>

Source§

fn negotiate_and_render( value: &T, accept: Option<&str>, ) -> Result<(Vec<u8>, &'static str), String>

Source§

impl<T, F1, F2, F3> NegotiateFormats<T> for (F1, F2, F3)
where F1: ContentFormat, F2: ContentFormat, F3: ContentFormat, T: RenderAs<F1> + RenderAs<F2> + RenderAs<F3>,

Source§

fn supported_types() -> Vec<&'static str>

Source§

fn negotiate_and_render( value: &T, accept: Option<&str>, ) -> Result<(Vec<u8>, &'static str), String>

Source§

impl<T, F1, F2, F3, F4> NegotiateFormats<T> for (F1, F2, F3, F4)
where F1: ContentFormat, F2: ContentFormat, F3: ContentFormat, F4: ContentFormat, T: RenderAs<F1> + RenderAs<F2> + RenderAs<F3> + RenderAs<F4>,

Source§

fn supported_types() -> Vec<&'static str>

Source§

fn negotiate_and_render( value: &T, accept: Option<&str>, ) -> Result<(Vec<u8>, &'static str), String>

Source§

impl<T, F1, F2, F3, F4, F5> NegotiateFormats<T> for (F1, F2, F3, F4, F5)
where F1: ContentFormat, F2: ContentFormat, F3: ContentFormat, F4: ContentFormat, F5: ContentFormat, T: RenderAs<F1> + RenderAs<F2> + RenderAs<F3> + RenderAs<F4> + RenderAs<F5>,

Source§

fn supported_types() -> Vec<&'static str>

Source§

fn negotiate_and_render( value: &T, accept: Option<&str>, ) -> Result<(Vec<u8>, &'static str), String>

Source§

impl<T, F1, F2, F3, F4, F5, F6> NegotiateFormats<T> for (F1, F2, F3, F4, F5, F6)
where F1: ContentFormat, F2: ContentFormat, F3: ContentFormat, F4: ContentFormat, F5: ContentFormat, F6: ContentFormat, T: RenderAs<F1> + RenderAs<F2> + RenderAs<F3> + RenderAs<F4> + RenderAs<F5> + RenderAs<F6>,

Source§

fn supported_types() -> Vec<&'static str>

Source§

fn negotiate_and_render( value: &T, accept: Option<&str>, ) -> Result<(Vec<u8>, &'static str), String>

Implementors§