Skip to content

Commit

Permalink
refactor(common): move compat constructor to method
Browse files Browse the repository at this point in the history
  • Loading branch information
tottoto committed Oct 22, 2023
1 parent dd638b5 commit 49164f8
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions src/common/io/compat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ use std::task::{Context, Poll};
#[derive(Debug)]
pub(crate) struct Compat<T>(pub(crate) T);

pub(crate) fn compat<T>(io: T) -> Compat<T> {
Compat(io)
}

impl<T> Compat<T> {
pub(crate) fn new(io: T) -> Self {
Compat(io)
}

fn p(self: Pin<&mut Self>) -> Pin<&mut T> {
// SAFETY: The simplest of projections. This is just
// a wrapper, we don't do anything that would undo the projection.
Expand Down
2 changes: 1 addition & 1 deletion src/common/io/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ mod compat;
mod rewind;

#[cfg(all(any(feature = "client", feature = "server"), feature = "http2"))]
pub(crate) use self::compat::{compat, Compat};
pub(crate) use self::compat::Compat;
pub(crate) use self::rewind::Rewind;
2 changes: 1 addition & 1 deletion src/proto/h2/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ where
B::Error: Into<Box<dyn std::error::Error + Send + Sync>>,
{
let (h2_tx, mut conn) = new_builder(config)
.handshake::<_, SendBuf<B::Data>>(crate::common::io::compat(io))
.handshake::<_, SendBuf<B::Data>>(Compat::new(io))
.await
.map_err(crate::Error::new_h2)?;

Expand Down
2 changes: 1 addition & 1 deletion src/proto/h2/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ where
if config.enable_connect_protocol {
builder.enable_connect_protocol();
}
let handshake = builder.handshake(crate::common::io::compat(io));
let handshake = builder.handshake(crate::common::io::Compat::new(io));

let bdp = if config.adaptive_window {
Some(config.initial_stream_window_size)
Expand Down

0 comments on commit 49164f8

Please sign in to comment.