Skip to main content

OutgoingBody

Trait OutgoingBody 

Source
pub trait OutgoingBody {
    type Error: Into<IntoHttpError>;

    // Required methods
    fn content_type(&self) -> Option<HeaderValue>;
    fn try_into_buf<T: Default + BufMut + AsRef<[u8]>>(
        self,
    ) -> Result<T, Self::Error>;
}
Available on crate feature api only.
Expand description

HTTP message body pre-serialization.

Required Associated Types§

Source

type Error: Into<IntoHttpError>

The type of error that can happen in try_info_buf.

Required Methods§

Source

fn content_type(&self) -> Option<HeaderValue>

The value for the Content-Type HTTP header for this body, if there is one.

This is the value set if the request or response type does not set one dynamically, for example with the #[ruma_api(header = CONTENT_TYPE)] attribute.

If this is None, no Content-Type HTTP header is added.

Source

fn try_into_buf<T: Default + BufMut + AsRef<[u8]>>( self, ) -> Result<T, Self::Error>

Turn self into a byte buffer (copying a raw body or serializing a JSON one).

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl OutgoingBody for BytesBody

Source§

impl<const TRULY_EMPTY: bool> OutgoingBody for EmptyBody<TRULY_EMPTY>