Skip to content

Commit

Permalink
docs: is_end_stream is a hint (#143)
Browse files Browse the repository at this point in the history
  • Loading branch information
seanmonstar authored Jan 28, 2025
1 parent 86fdf00 commit 261b2df
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions http-body/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,21 @@ pub trait Body {
cx: &mut Context<'_>,
) -> Poll<Option<Result<Frame<Self::Data>, Self::Error>>>;

/// Returns `true` when the end of stream has been reached.
/// A hint that may return `true` when the end of stream has been reached.
///
/// An end of stream means that `poll_frame` will return `None`.
///
/// A return value of `false` **does not** guarantee that a value will be
/// returned from `poll_frame`.
/// returned from `poll_frame`. Combinators or other implementations may
/// not be able to know the end of stream has been reached for this hint.
///
/// Returning `true` allows consumers of this body to optimize, such as not
/// calling `poll_frame` again.
fn is_end_stream(&self) -> bool {
false
}

/// Returns the bounds on the remaining length of the stream.
/// A hint that returns the bounds on the remaining length of the stream.
///
/// When the **exact** remaining length of the stream is known, the upper bound will be set and
/// will equal the lower bound.
Expand Down

0 comments on commit 261b2df

Please sign in to comment.