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(rt): rename to Http2ClientConnExec and Http2ServerConnExec #3399

Merged
merged 1 commit into from
Nov 10, 2023
Merged
Show file tree
Hide file tree
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
14 changes: 7 additions & 7 deletions src/client/conn/http2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use super::super::dispatch;
use crate::body::{Body, Incoming as IncomingBody};
use crate::common::time::Time;
use crate::proto;
use crate::rt::bounds::ExecutorClient;
use crate::rt::bounds::Http2ClientConnExec;
use crate::rt::Timer;

/// The sender side of an established connection.
Expand All @@ -41,7 +41,7 @@ pub struct Connection<T, B, E>
where
T: Read + Write + 'static + Unpin,
B: Body + 'static,
E: ExecutorClient<B, T> + Unpin,
E: Http2ClientConnExec<B, T> + Unpin,
B::Error: Into<Box<dyn Error + Send + Sync>>,
{
inner: (PhantomData<T>, proto::h2::ClientTask<B, E, T>),
Expand Down Expand Up @@ -73,7 +73,7 @@ where
B: Body + 'static,
B::Data: Send,
B::Error: Into<Box<dyn Error + Send + Sync>>,
E: ExecutorClient<B, T> + Unpin + Clone,
E: Http2ClientConnExec<B, T> + Unpin + Clone,
{
Builder::new(exec).handshake(io).await
}
Expand Down Expand Up @@ -202,7 +202,7 @@ where
B: Body + Unpin + 'static,
B::Data: Send,
B::Error: Into<Box<dyn Error + Send + Sync>>,
E: ExecutorClient<B, T> + Unpin,
E: Http2ClientConnExec<B, T> + Unpin,
{
/// Returns whether the [extended CONNECT protocol][1] is enabled or not.
///
Expand All @@ -222,7 +222,7 @@ impl<T, B, E> fmt::Debug for Connection<T, B, E>
where
T: Read + Write + fmt::Debug + 'static + Unpin,
B: Body + 'static,
E: ExecutorClient<B, T> + Unpin,
E: Http2ClientConnExec<B, T> + Unpin,
B::Error: Into<Box<dyn Error + Send + Sync>>,
{
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
Expand All @@ -237,7 +237,7 @@ where
B::Data: Send,
E: Unpin,
B::Error: Into<Box<dyn Error + Send + Sync>>,
E: ExecutorClient<B, T> + 'static + Send + Sync + Unpin,
E: Http2ClientConnExec<B, T> + 'static + Send + Sync + Unpin,
{
type Output = crate::Result<()>;

Expand Down Expand Up @@ -407,7 +407,7 @@ where
B: Body + 'static,
B::Data: Send,
B::Error: Into<Box<dyn Error + Send + Sync>>,
Ex: ExecutorClient<B, T> + Unpin,
Ex: Http2ClientConnExec<B, T> + Unpin,
{
let opts = self.clone();

Expand Down
10 changes: 5 additions & 5 deletions src/proto/h2/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ use crate::ext::Protocol;
use crate::headers;
use crate::proto::h2::UpgradedSendStream;
use crate::proto::Dispatched;
use crate::rt::bounds::ExecutorClient;
use crate::rt::bounds::Http2ClientConnExec;
use crate::upgrade::Upgraded;
use crate::{Request, Response};
use h2::client::ResponseFuture;
Expand Down Expand Up @@ -118,7 +118,7 @@ where
T: Read + Write + Unpin + 'static,
B: Body + 'static,
B::Data: Send + 'static,
E: ExecutorClient<B, T> + Unpin,
E: Http2ClientConnExec<B, T> + Unpin,
B::Error: Into<Box<dyn std::error::Error + Send + Sync>>,
{
let (h2_tx, mut conn) = new_builder(config)
Expand Down Expand Up @@ -405,7 +405,7 @@ where
impl<B, E, T> ClientTask<B, E, T>
where
B: Body + 'static,
E: ExecutorClient<B, T> + Unpin,
E: Http2ClientConnExec<B, T> + Unpin,
B::Error: Into<Box<dyn std::error::Error + Send + Sync>>,
T: Read + Write + Unpin,
{
Expand Down Expand Up @@ -457,7 +457,7 @@ impl<B, E, T> ClientTask<B, E, T>
where
B: Body + 'static + Unpin,
B::Data: Send,
E: ExecutorClient<B, T> + Unpin,
E: Http2ClientConnExec<B, T> + Unpin,
B::Error: Into<Box<dyn std::error::Error + Send + Sync>>,
T: Read + Write + Unpin,
{
Expand Down Expand Up @@ -593,7 +593,7 @@ where
B: Body + 'static + Unpin,
B::Data: Send,
B::Error: Into<Box<dyn std::error::Error + Send + Sync>>,
E: ExecutorClient<B, T> + 'static + Send + Sync + Unpin,
E: Http2ClientConnExec<B, T> + 'static + Send + Sync + Unpin,
T: Read + Write + Unpin,
{
type Output = crate::Result<Dispatched>;
Expand Down
8 changes: 4 additions & 4 deletions src/proto/h2/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use crate::headers;
use crate::proto::h2::ping::Recorder;
use crate::proto::h2::{H2Upgraded, UpgradedSendStream};
use crate::proto::Dispatched;
use crate::rt::bounds::Http2ConnExec;
use crate::rt::bounds::Http2ServerConnExec;
use crate::rt::{Read, Write};
use crate::service::HttpService;

Expand Down Expand Up @@ -112,7 +112,7 @@ where
S: HttpService<IncomingBody, ResBody = B>,
S::Error: Into<Box<dyn StdError + Send + Sync>>,
B: Body + 'static,
E: Http2ConnExec<S::Future, B>,
E: Http2ServerConnExec<S::Future, B>,
{
pub(crate) fn new(
io: T,
Expand Down Expand Up @@ -188,7 +188,7 @@ where
S: HttpService<IncomingBody, ResBody = B>,
S::Error: Into<Box<dyn StdError + Send + Sync>>,
B: Body + 'static,
E: Http2ConnExec<S::Future, B>,
E: Http2ServerConnExec<S::Future, B>,
{
type Output = crate::Result<Dispatched>;

Expand Down Expand Up @@ -242,7 +242,7 @@ where
where
S: HttpService<IncomingBody, ResBody = B>,
S::Error: Into<Box<dyn StdError + Send + Sync>>,
E: Http2ConnExec<S::Future, B>,
E: Http2ServerConnExec<S::Future, B>,
{
if self.closing.is_none() {
loop {
Expand Down
14 changes: 7 additions & 7 deletions src/rt/bounds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
//! implemented by implementing another trait.

#[cfg(all(feature = "server", feature = "http2"))]
pub use self::h2::Http2ConnExec;
pub use self::h2::Http2ServerConnExec;

#[cfg(all(feature = "client", feature = "http2"))]
pub use self::h2_client::ExecutorClient;
pub use self::h2_client::Http2ClientConnExec;

#[cfg(all(feature = "client", feature = "http2"))]
#[cfg_attr(docsrs, doc(cfg(all(feature = "server", feature = "http2"))))]
#[cfg_attr(docsrs, doc(cfg(all(feature = "client", feature = "http2"))))]
mod h2_client {
use std::{error::Error, future::Future};

Expand All @@ -25,7 +25,7 @@ mod h2_client {
/// This trait is sealed and cannot be implemented for types outside this crate.
///
/// [`Executor`]: crate::rt::Executor
pub trait ExecutorClient<B, T>: sealed_client::Sealed<(B, T)>
pub trait Http2ClientConnExec<B, T>: sealed_client::Sealed<(B, T)>
where
B: http_body::Body,
B::Error: Into<Box<dyn Error + Send + Sync>>,
Expand All @@ -35,7 +35,7 @@ mod h2_client {
fn execute_h2_future(&mut self, future: H2ClientFuture<B, T>);
}

impl<E, B, T> ExecutorClient<B, T> for E
impl<E, B, T> Http2ClientConnExec<B, T> for E
where
E: Executor<H2ClientFuture<B, T>>,
B: http_body::Body + 'static,
Expand Down Expand Up @@ -78,13 +78,13 @@ mod h2 {
/// This trait is sealed and cannot be implemented for types outside this crate.
///
/// [`Executor`]: crate::rt::Executor
pub trait Http2ConnExec<F, B: Body>: sealed::Sealed<(F, B)> + Clone {
pub trait Http2ServerConnExec<F, B: Body>: sealed::Sealed<(F, B)> + Clone {
#[doc(hidden)]
fn execute_h2stream(&mut self, fut: H2Stream<F, B>);
}

#[doc(hidden)]
impl<E, F, B> Http2ConnExec<F, B> for E
impl<E, F, B> Http2ServerConnExec<F, B> for E
where
E: Executor<H2Stream<F, B>> + Clone,
H2Stream<F, B>: Future<Output = ()>,
Expand Down
12 changes: 6 additions & 6 deletions src/server/conn/http2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use pin_project_lite::pin_project;

use crate::body::{Body, Incoming as IncomingBody};
use crate::proto;
use crate::rt::bounds::Http2ConnExec;
use crate::rt::bounds::Http2ServerConnExec;
use crate::service::HttpService;
use crate::{common::time::Time, rt::Timer};

Expand Down Expand Up @@ -63,7 +63,7 @@ where
I: Read + Write + Unpin,
B: Body + 'static,
B::Error: Into<Box<dyn StdError + Send + Sync>>,
E: Http2ConnExec<S::Future, B>,
E: Http2ServerConnExec<S::Future, B>,
{
/// Start a graceful shutdown process for this connection.
///
Expand All @@ -87,7 +87,7 @@ where
I: Read + Write + Unpin + 'static,
B: Body + 'static,
B::Error: Into<Box<dyn StdError + Send + Sync>>,
E: Http2ConnExec<S::Future, B>,
E: Http2ServerConnExec<S::Future, B>,
{
type Output = crate::Result<()>;

Expand All @@ -109,9 +109,9 @@ impl<E> Builder<E> {
/// Create a new connection builder.
///
/// This starts with the default options, and an executor which is a type
/// that implements [`Http2ConnExec`] trait.
/// that implements [`Http2ServerConnExec`] trait.
///
/// [`Http2ConnExec`]: crate::rt::bounds::Http2ConnExec
/// [`Http2ServerConnExec`]: crate::rt::bounds::Http2ServerConnExec
pub fn new(exec: E) -> Self {
Self {
exec: exec,
Expand Down Expand Up @@ -262,7 +262,7 @@ impl<E> Builder<E> {
Bd: Body + 'static,
Bd::Error: Into<Box<dyn StdError + Send + Sync>>,
I: Read + Write + Unpin,
E: Http2ConnExec<S::Future, Bd>,
E: Http2ServerConnExec<S::Future, Bd>,
{
let proto = proto::h2::Server::new(
io,
Expand Down