hyper/body/
mod.rs

1//! Streaming bodies for Requests and Responses
2//!
3//! For both [Clients](crate::client) and [Servers](crate::server), requests and
4//! responses use streaming bodies, instead of complete buffering. This
5//! allows applications to not use memory they don't need, and allows exerting
6//! back-pressure on connections by only reading when asked.
7//!
8//! There are two pieces to this in hyper:
9//!
10//! - **The [`Body`] trait** describes all possible bodies.
11//!   hyper allows any body type that implements `Body`, allowing
12//!   applications to have fine-grained control over their streaming.
13//! - **The [`Incoming`] concrete type**, which is an implementation
14//!   of `Body`, and returned by hyper as a "receive stream" (so, for server
15//!   requests and client responses).
16//!
17//! There are additional implementations available in [`http-body-util`][],
18//! such as a `Full` or `Empty` body.
19//!
20//! [`http-body-util`]: https://docs.rs/http-body-util
21
22pub use bytes::{Buf, Bytes};
23pub use http_body::Body;
24pub use http_body::Frame;
25pub use http_body::SizeHint;
26
27pub use self::incoming::Incoming;
28
29#[cfg(all(any(feature = "client", feature = "server"), feature = "http1"))]
30pub(crate) use self::incoming::Sender;
31#[cfg(all(
32    any(feature = "http1", feature = "http2"),
33    any(feature = "client", feature = "server")
34))]
35pub(crate) use self::length::DecodedLength;
36
37mod incoming;
38#[cfg(all(
39    any(feature = "http1", feature = "http2"),
40    any(feature = "client", feature = "server")
41))]
42mod length;
43
44fn _assert_send_sync() {
45    fn _assert_send<T: Send>() {}
46    fn _assert_sync<T: Sync>() {}
47
48    _assert_send::<Incoming>();
49    _assert_sync::<Incoming>();
50}