feat(client): `TrySendError<T>` is `From<Error>` by cratelyn · Pull Request #3883 · hyperium/hyper

@cratelyn

@cratelyn cratelyn marked this pull request as ready for review

May 5, 2025 15:10

cratelyn added a commit to cratelyn/hyper that referenced this pull request

May 22, 2025
this change is motivated by aiming to use interfaces like
`hyper::client::conn::http2::SendRequest::try_send_request()` or
`hyper::client::conn::http1::SendRequest::try_send_request()` in the
context of tower middleware; the `Service<T>` trait's signature is such
that the same error type be returned from `Service::poll_ready()` and
`Service::call()`.

this means that services that might resolve to a recovered message may
call `try_poll_ready` when polling for readiness.

this avoids making `TrySendError<T>` constructable externally, see hyperium#3883
as an alternate approach that was considered.

Signed-off-by: katelyn martin <git@katelyn.world>

cratelyn added a commit to cratelyn/hyper that referenced this pull request

Jul 29, 2025
this commit introduces a `std::error::Error` implementation for
`hyper::client::conn::TrySendError`.

this allows callers of
`hyper::client::conn::http2::SendRequest::try_send_request()` or
`hyper::client::conn::http1::SendRequest::try_send_request()` to box a
`TrySendError<T>` without discarding a potentially recovered message.

a `std::fmt::Display` implementation is added in this commit, because it
is a prerequisite for implementations of `std::error::Error`.

for some previous discussion on this topic, see "_other options_" here:
hyperium#3883 (comment).

Ref: hyperium#3883
Ref: hyperium#3892
Signed-off-by: katelyn martin <git@katelyn.world>