pub trait BodyCallback: Send + Sync {
    fn make_new(&self) -> Box<dyn BodyCallback>;

    fn update(
        &mut self,
        bytes: &[u8]
    ) -> Result<(), Box<dyn Error + Send + Sync>> { ... } fn trailers(
        &self
    ) -> Result<Option<HeaderMap<HeaderValue>>, Box<dyn Error + Send + Sync>> { ... } }
Expand description

A callback that, when inserted into a request body, will be called for corresponding lifecycle events.

Required Methods

Create a new BodyCallback from an existing one. This is called when a BodyCallback needs to be re-initialized with default state. For example: when a request has a body that needs to be rebuilt, all callbacks for that body need to be run again but with a fresh internal state.

Provided Methods

This lifecycle function is called for each chunk successfully read. If an error occurs while reading a chunk, this method will not be called. This method takes &mut self so that implementors may modify an implementing struct/enum’s internal state. Implementors may return an error.

This callback is called once all chunks have been read. If the callback encountered one or more errors while running updates, this is how those errors are raised. Implementors may return a HeaderMap that will be appended to the HTTP body as a trailer. This is only useful to do for streaming requests.

Trait Implementations

This lifecycle function is called for each chunk successfully read. If an error occurs while reading a chunk, this method will not be called. This method takes &mut self so that implementors may modify an implementing struct/enum’s internal state. Implementors may return an error. Read more

This callback is called once all chunks have been read. If the callback encountered one or more errors while running updates, this is how those errors are raised. Implementors may return a HeaderMap that will be appended to the HTTP body as a trailer. This is only useful to do for streaming requests. Read more

Create a new BodyCallback from an existing one. This is called when a BodyCallback needs to be re-initialized with default state. For example: when a request has a body that needs to be rebuilt, all callbacks for that body need to be run again but with a fresh internal state. Read more

Implementations on Foreign Types

Implementors