Skip to content

feat(util): add InspectErr, InspectFrame combinators - #161

Merged
cratelyn merged 1 commit into
hyperium:masterfrom
cratelyn:kate/inspect-combinators
Nov 10, 2025
Merged

feat(util): add InspectErr, InspectFrame combinators#161
cratelyn merged 1 commit into
hyperium:masterfrom
cratelyn:kate/inspect-combinators

Conversation

@cratelyn

Copy link
Copy Markdown
Member

fixes#160.

the standard library has introduced conventions for combinators that accept callbacks that "inspect" a value, upon being provided a reference to a yielded value.

for example, Result::inspect() and Result::inspect_err() allow callers to e.g. log an Ok(_) or Err(_) value. Iterator::inspect() similarly allows callers to apply a layer of functionality to inspect items as they are yielded by the inner iterator.

this commit introduces a pair of combinators to http_body_util, called InspectErr<B, F> and InspectFrame<B, F>. these allow callers to inspect errors and frames yielded by an inner body. these are constructed by calling BodyExt::inspect_err() and BodyExt::inspect_frame(), respectively.

@cratelyncratelyn self-assigned this Nov 7, 2025
@cratelyn

Copy link
Copy Markdown
MemberAuthor

CI / doc action is failing due to unrelated changes.

@cratelyn
cratelyn marked this pull request as ready for review November 7, 2025 18:54

@seanmonstarseanmonstar left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

@cratelyn

Copy link
Copy Markdown
MemberAuthor

i opened #162 to address these errors in CI.

@cratelyn
cratelynforce-pushed the kate/inspect-combinators branch from f2ea117 to 1e9c77fCompareNovember 10, 2025 19:01
fixeshyperium#160.
the standard library has introduced conventions for combinators that
accept callbacks that "inspect" a value, upon being provided a reference
to a yielded value.
for example, `Result::inspect()` and `Result::inspect_err()` allow
callers to e.g. log an `Ok(_)` or `Err(_)` value. `Iterator::inspect()`
similarly allows callers to apply a layer of functionality to inspect
items as they are yielded by the inner iterator.
this commit introduces a pair of combinators to `http_body_util`, called
`InspectErr<B, F>` and `InspectFrame<B, F>`. these allow callers to
inspect errors and frames yielded by an inner body. these are
constructed by calling `BodyExt::inspect_err()` and
`BodyExt::inspect_frame()`, respectively.
Signed-off-by: katelyn martin <git@katelyn.world>
@cratelyn
cratelynforce-pushed the kate/inspect-combinators branch from 1e9c77f to 2db6fdeCompareNovember 10, 2025 21:16
@cratelyn

Copy link
Copy Markdown
MemberAuthor

rebased on main now that #162 has merged.

@cratelyn
cratelyn merged commit 915d6d5 into hyperium:masterNov 10, 2025
8 checks passed
@cratelyn
cratelyn deleted the kate/inspect-combinators branch August 20, 2026 14:55
Sign up for freeto 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.

Add BodyExt::inspect_frame()

2 participants

@cratelyn@seanmonstar