Skip to content

Commit c22fc07

Browse files
authored
docs(body): add example to body::Incoming (#3383)
And explain that users don't "create" one. cc #3067
1 parent 52b27fa commit c22fc07

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/body/incoming.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,20 @@ type BodySender = mpsc::Sender<Result<Bytes, crate::Error>>;
1919
type TrailersSender = oneshot::Sender<HeaderMap>;
2020

2121
/// A stream of `Bytes`, used when receiving bodies from the network.
22+
///
23+
/// Note that Users should not instantiate this struct directly. When working with the hyper client,
24+
/// `Incoming` is returned to you in responses. Similarly, when operating with the hyper server,
25+
/// it is provided within requests.
26+
///
27+
/// # Examples
28+
///
29+
/// ```rust,ignore
30+
/// async fn echo(
31+
/// req: Request<hyper::body::Incoming>,
32+
/// ) -> Result<Response<BoxBody<Bytes, hyper::Error>>, hyper::Error> {
33+
/// //Here, you can process `Incoming`
34+
/// }
35+
/// ```
2236
#[must_use = "streams do nothing unless polled"]
2337
pub struct Incoming {
2438
kind: Kind,

0 commit comments

Comments
 (0)