pub trait IncomingBodyExt {
// Required methods
fn stream(self) -> BodyDataStream<Self>
where Self: Sized;
async fn bytes(self) -> Result<Bytes, ErrorCode>;
}http only.Expand description
Extension trait providing convenient methods for consuming an IncomingBody.
This trait defines common patterns for handling HTTP body data in
asynchronous contexts. It allows converting the body into a stream
or fully collecting it into memory as a Bytes buffer.
Required Methods§
Sourcefn stream(self) -> BodyDataStream<Self>where
Self: Sized,
fn stream(self) -> BodyDataStream<Self>where
Self: Sized,
Convert this IncomingBody into a BodyDataStream.
This method enables iteration over the body’s data chunks as they arrive, without collecting them all into memory at once. It is suitable for processing large or streaming payloads efficiently.
Sourceasync fn bytes(self) -> Result<Bytes, ErrorCode>
async fn bytes(self) -> Result<Bytes, ErrorCode>
Consume this IncomingBody and collect it into a single Bytes buffer.
This method reads the entire body asynchronously and returns the concatenated contents. It is best suited for small or bounded-size payloads where holding all data in memory is acceptable.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementations on Foreign Types§
Source§impl<T: IncomingMessage> IncomingBodyExt for IncomingBody<T>
impl<T: IncomingMessage> IncomingBodyExt for IncomingBody<T>
Source§fn stream(self) -> BodyDataStream<Self>where
Self: Sized,
fn stream(self) -> BodyDataStream<Self>where
Self: Sized,
Convert this IncomingBody into a BodyDataStream.