Skip to content

Commit

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

cc #3067
  • Loading branch information
ZhangHanDong committed Nov 13, 2023
1 parent 52b27fa commit c22fc07
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 c22fc07

Please sign in to comment.