Module http_body_util
Body types and combinators for hyper and the http-body ecosystem.
- Crate
::http_body_util. - docs.rs
- crates.io
- GitHub
http-body-util provides the concrete request and response body types
that hyper 1.x leaves out.
hyper defines only the Body trait
and Incoming, the body type of received messages.
Anything that sends or reads body bytes needs this crate.
The types used most:
Full- a body holding a single chunk of dataEmpty- a body with no data, forGETrequests and bodiless responsesBodyExt- extension methods on any body, notablycollectfor reading a whole body andboxedfor erasing its typeBoxBody- a type-erased body, for handlers that return different body types from different branchesLimited- caps the size of a body, to bound memory spent on untrusted inputStreamBody- a body built from aStreamof frames
Examples
Creating bodies and reading them back with collect:
use Bytes;
use block_on;
use ;
let body = new;
let bytes = block_on.unwrap.to_bytes;
assert_eq!;
let empty = new;
let bytes = block_on.unwrap.to_bytes;
assert!;
Returning different body types as one BoxBody:
use Bytes;
use block_on;
use ;
use Infallible;
let bytes = block_on.unwrap.to_bytes;
assert_eq!;
Modules
- channel A body backed by a channel.
-
combinators
Combinators for the
Bodytrait.
Structs
-
BodyDataStream
A data stream created from a
Body. -
BodyStream
A stream created from a
Body. - Channel A body backed by a channel.
-
Collected
A collected body produced by
BodyExt::collectwhich collects all the DATA frames and trailers. - Empty A body that is always empty.
- Full A body that consists of a single chunk.
- LengthLimitError An error returned when body length exceeds the configured limit.
- Limited A length limited body.
-
StreamBody
A body created from a
Stream.
Enums
Traits
-
BodyExt
An extension trait for
http_body::Bodyadding various combinators and adapters