From b15787cbd5845570419f00b6e26c6e24a336163a Mon Sep 17 00:00:00 2001 From: Jun Kurihara Date: Fri, 21 Jun 2024 07:03:13 +0900 Subject: [PATCH] chore: refactor and deps --- Cargo.toml | 2 +- rpxy-bin/Cargo.toml | 2 +- rpxy-certs/Cargo.toml | 2 +- rpxy-lib/Cargo.toml | 2 +- rpxy-lib/src/hyper_ext/body_incoming_like.rs | 22 ++++++-------------- 5 files changed, 10 insertions(+), 20 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index cd52b64..3884f20 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,5 @@ [workspace.package] -version = "0.8.0-alpha.2" +version = "0.8.0-alpha.3" authors = ["Jun Kurihara"] homepage = "https://github.com/junkurihara/rust-rpxy" repository = "https://github.com/junkurihara/rust-rpxy" diff --git a/rpxy-bin/Cargo.toml b/rpxy-bin/Cargo.toml index d04f453..1905692 100644 --- a/rpxy-bin/Cargo.toml +++ b/rpxy-bin/Cargo.toml @@ -29,7 +29,7 @@ rpxy-lib = { path = "../rpxy-lib/", default-features = false, features = [ mimalloc = { version = "*", default-features = false } anyhow = "1.0.86" -rustc-hash = "1.1.0" +rustc-hash = "2.0.0" serde = { version = "1.0.203", default-features = false, features = ["derive"] } tokio = { version = "1.38.0", default-features = false, features = [ "net", diff --git a/rpxy-certs/Cargo.toml b/rpxy-certs/Cargo.toml index a4a179d..0cb9a87 100644 --- a/rpxy-certs/Cargo.toml +++ b/rpxy-certs/Cargo.toml @@ -15,7 +15,7 @@ default = ["http3"] http3 = [] [dependencies] -rustc-hash = { version = "1.1.0" } +rustc-hash = { version = "2.0.0" } tracing = { version = "0.1.40" } derive_builder = { version = "0.20.0" } thiserror = { version = "1.0.61" } diff --git a/rpxy-lib/Cargo.toml b/rpxy-lib/Cargo.toml index d052223..18bf4da 100644 --- a/rpxy-lib/Cargo.toml +++ b/rpxy-lib/Cargo.toml @@ -32,7 +32,7 @@ webpki-roots = ["rustls-backend", "hyper-rustls/webpki-tokio"] [dependencies] rand = "0.8.5" -rustc-hash = "1.1.0" +rustc-hash = "2.0.0" bytes = "1.6.0" derive_builder = "0.20.0" futures = { version = "0.3.30", features = ["alloc", "async-await"] } diff --git a/rpxy-lib/src/hyper_ext/body_incoming_like.rs b/rpxy-lib/src/hyper_ext/body_incoming_like.rs index 9307b7f..1a86409 100644 --- a/rpxy-lib/src/hyper_ext/body_incoming_like.rs +++ b/rpxy-lib/src/hyper_ext/body_incoming_like.rs @@ -31,12 +31,12 @@ macro_rules! ready { type BodySender = mpsc::Sender>; type TrailersSender = oneshot::Sender; -const MAX_LEN: u64 = std::u64::MAX - 2; +const MAX_LEN: u64 = u64::MAX - 2; #[derive(Clone, Copy, PartialEq, Eq)] pub(crate) struct DecodedLength(u64); impl DecodedLength { - pub(crate) const CLOSE_DELIMITED: DecodedLength = DecodedLength(::std::u64::MAX); - pub(crate) const CHUNKED: DecodedLength = DecodedLength(::std::u64::MAX - 1); + pub(crate) const CLOSE_DELIMITED: DecodedLength = DecodedLength(u64::MAX); + pub(crate) const CHUNKED: DecodedLength = DecodedLength(u64::MAX - 1); pub(crate) const ZERO: DecodedLength = DecodedLength(0); #[allow(dead_code)] @@ -110,10 +110,7 @@ impl Body for IncomingLike { type Data = Bytes; type Error = RpxyError; - fn poll_frame( - mut self: Pin<&mut Self>, - cx: &mut Context<'_>, - ) -> Poll, Self::Error>>> { + fn poll_frame(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll, Self::Error>>> { self.want_tx.send(WANT_READY); if !self.data_rx.is_terminated() { @@ -156,10 +153,7 @@ impl Sender { pub(crate) fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll> { // Check if the receiver end has tried polling for the body yet ready!(self.poll_want(cx)?); - self - .data_tx - .poll_ready(cx) - .map_err(|_| RpxyError::HyperIncomingLikeNewClosed) + self.data_tx.poll_ready(cx).map_err(|_| RpxyError::HyperIncomingLikeNewClosed) } fn poll_want(&mut self, cx: &mut Context<'_>) -> Poll> { @@ -256,11 +250,7 @@ mod tests { assert_eq!(mem::size_of::(), mem::size_of::() * 5, "Sender"); - assert_eq!( - mem::size_of::(), - mem::size_of::>(), - "Option" - ); + assert_eq!(mem::size_of::(), mem::size_of::>(), "Option"); } #[test] fn size_hint() {