Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: is_end_stream is a hint #143

Merged
merged 1 commit into from
Jan 28, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions http-body/src/lib.rs
Original file line number Diff line number Diff line change
@@ -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.
Loading