pub trait BodyHandleExt {
    // Required methods
    fn get_trailer_names<'a>(
        &'a self,
        buf_size: usize
    ) -> Result<Box<dyn Iterator<Item = Result<HeaderName, BufferSizeError>> + 'a>, BodyHandleError>;
    fn get_trailer_value(
        &self,
        name: &HeaderName,
        max_len: usize
    ) -> Result<Result<Option<HeaderValue>, BufferSizeError>, BodyHandleError>;
    fn get_trailer_values<'a>(
        &'a self,
        name: &'a HeaderName,
        max_len: usize
    ) -> Result<Box<dyn Iterator<Item = Result<HeaderValue, BufferSizeError>> + 'a>, BodyHandleError>;
}
Expand description

Extensions to the crate::handle::BodyHandle type to support trailers.

Required Methods§

source

fn get_trailer_names<'a>( &'a self, buf_size: usize ) -> Result<Box<dyn Iterator<Item = Result<HeaderName, BufferSizeError>> + 'a>, BodyHandleError>

Get the names of the trailers associated with this body.

The resulting iterator will produce either the header names or an indication that the provided buffer size was too small. In that case, calling with a larger buffer size (information about how large a buffer is recommended is provided in BufferSizeError) should resolve the situation.

§Trailers

Trailers can be tricky to access. You must completely read all bytes from the body before calling this function. The outermost Result reflects this requirement; if you receive BodyHandleError::TrailersNotReady, there are potentially more bytes available in the body that you must read.

§Stability

This is part of an experimental API that is subject to change or removal even in minor versions of this crate.

source

fn get_trailer_value( &self, name: &HeaderName, max_len: usize ) -> Result<Result<Option<HeaderValue>, BufferSizeError>, BodyHandleError>

Get the value for the trailer with the given name.

If there are multiple values for this header, only one is returned, which may be any of the values. See BodyHandleExt::get_trailer_values if you need to get all of the values.

There are several options in the return value, ignoring the common tailer case in which you must read more data from the body:

  • Ok(Some(value)): The trailer existed, and had the given value
  • Ok(None): A trailer with that name does not exist
  • Err(BufferSizeError): The trailer existed, but the provided max length was too small.

In the last case, BufferSizeError should provide information about what size buffer will be required to hold the requested data.

§Trailers

Trailers can be tricky to access. You must completely read all bytes from the body before calling this function. The outermost Result reflects this requirement; if you receive BodyHandleError::TrailersNotReady, there are potentially more bytes available in the body that you must read.

§Stability

This is part of an experimental API that is subject to change or removal even in minor versions of this crate.

source

fn get_trailer_values<'a>( &'a self, name: &'a HeaderName, max_len: usize ) -> Result<Box<dyn Iterator<Item = Result<HeaderValue, BufferSizeError>> + 'a>, BodyHandleError>

Get all the values associated with the trailer with the given name.

As opposed to BodyHandleExt::get_trailer_value, this function returns all of the values for this trailer.

§Trailers

Trailers can be tricky to access. You must completely read all bytes from the body before calling this function. The outermost Result reflects this requirement; if you receive BodyHandleError::TrailersNotReady, there are potentially more bytes available in the body that you must read.

§Stability

This is part of an experimental API that is subject to change or removal even in minor versions of this crate.

Implementors§