Skip to content

feat(client/dispatch): try_poll_ready() methods #3892

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

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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
30 changes: 30 additions & 0 deletions src/client/dispatch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,36 @@ impl<T> TrySendError<T> {
}
}

impl<B> crate::client::conn::http1::SendRequest<B> {
/// Polls to determine whether this sender can be used yet for a request.
///
/// If the associated connection is closed, this returns a [`TrySendError<T>`].
pub fn try_poll_ready(
&mut self,
cx: &mut Context<'_>,
) -> Poll<Result<(), TrySendError<Request<B>>>> {
self.poll_ready(cx).map_err(|error| TrySendError {
error,
message: None,
})
}
}

impl<B> crate::client::conn::http2::SendRequest<B> {
/// Polls to determine whether this sender can be used yet for a request.
///
/// If the associated connection is closed, this returns a [`TrySendError<T>`].
pub fn try_poll_ready(
&mut self,
cx: &mut Context<'_>,
) -> Poll<Result<(), TrySendError<Request<B>>>> {
self.poll_ready(cx).map_err(|error| TrySendError {
error,
message: None,
})
}
}

#[cfg(feature = "http2")]
pin_project! {
pub struct SendWhen<B>
Expand Down
Loading