Skip to content

Commit

Permalink
docs(body): add example to body::Incoming (hyperium#3383)
Browse files Browse the repository at this point in the history
And explain that users don't "create" one.

cc hyperium#3067
  • Loading branch information
ZhangHanDong authored and 0xE282B0 committed Jan 12, 2024
1 parent 5b8e8df commit 76e348c
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/body/incoming.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,20 @@ type BodySender = mpsc::Sender<Result<Bytes, crate::Error>>;
type TrailersSender = oneshot::Sender<HeaderMap>;

/// A stream of `Bytes`, used when receiving bodies from the network.
///
/// Note that Users should not instantiate this struct directly. When working with the hyper client,
/// `Incoming` is returned to you in responses. Similarly, when operating with the hyper server,
/// it is provided within requests.
///
/// # Examples
///
/// ```rust,ignore
/// async fn echo(
/// req: Request<hyper::body::Incoming>,
/// ) -> Result<Response<BoxBody<Bytes, hyper::Error>>, hyper::Error> {
/// //Here, you can process `Incoming`
/// }
/// ```
#[must_use = "streams do nothing unless polled"]
pub struct Incoming {
kind: Kind,
Expand Down

0 comments on commit 76e348c

Please sign in to comment.