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

feat(util): introduce a "fused" body combinator #145

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

cratelyn
Copy link
Contributor

@cratelyn cratelyn commented Feb 3, 2025

this commit introduces a new Body combinator to the http-body-util library, http_body_util::combinators::Fuse<B>.

this combinator is roughly equivalent to the std::iter::Fuse<I> iterator, which returns None after the inner iterator returns it once.

while bodies should return Poll::Ready(None) indefinitely after reaching the end of the stream or returning an error, this combinator can help prevent further polling of an underlying body implementation, in the same manner that std::iter::Iterator::fuse() helps prevent an underlying iterator that might e.g. yield Some(value) after yielding None, or panic.

@cratelyn cratelyn force-pushed the fuse branch 2 times, most recently from 4c77dab to 02e11f5 Compare February 3, 2025 15:16
this commit introduces a new `Body` combinator to the `http-body-util`
library, `http_body_util::combinators::Fuse<B>`.

this combinator is roughly equivalent to the `std::iter::Fuse<I>`
iterator, which returns `None` after the inner iterator returns it once.

while bodies *should* return `Poll::Ready(None)` indefinitely after
reaching the end of the stream or returning an error, this combinator
can help prevent further polling of an underlying body implementation,
in the same manner that `std::iter::Iterator::fuse()` helps prevent an
underlying iterator that might e.g. yield `Some(value)` after yielding
`None`, or panic.

Signed-off-by: katelyn martin <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant