Trait aws_smithy_http::callback::BodyCallback
source · [−]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
sourcefn make_new(&self) -> Box<dyn BodyCallback>
fn make_new(&self) -> Box<dyn BodyCallback>
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
sourceimpl BodyCallback for Box<dyn BodyCallback>
impl BodyCallback for Box<dyn BodyCallback>
sourcefn update(&mut self, bytes: &[u8]) -> Result<(), Box<dyn Error + Send + Sync>>
fn update(&mut self, bytes: &[u8]) -> Result<(), Box<dyn Error + Send + Sync>>
&mut self so that implementors may modify an implementing
struct/enum’s internal state. Implementors may return an error. Read moresourcefn trailers(
&self
) -> Result<Option<HeaderMap<HeaderValue>>, Box<dyn Error + Send + Sync>>
fn trailers(
&self
) -> Result<Option<HeaderMap<HeaderValue>>, Box<dyn Error + Send + Sync>>
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 moresourcefn make_new(&self) -> Box<dyn BodyCallback>
fn make_new(&self) -> Box<dyn BodyCallback>
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