chore: refactor and deps

This commit is contained in:
Jun Kurihara 2024-06-21 07:03:13 +09:00
commit b15787cbd5
No known key found for this signature in database
GPG key ID: 48ADFD173ED22B03
5 changed files with 10 additions and 20 deletions

View file

@ -1,5 +1,5 @@
[workspace.package] [workspace.package]
version = "0.8.0-alpha.2" version = "0.8.0-alpha.3"
authors = ["Jun Kurihara"] authors = ["Jun Kurihara"]
homepage = "https://github.com/junkurihara/rust-rpxy" homepage = "https://github.com/junkurihara/rust-rpxy"
repository = "https://github.com/junkurihara/rust-rpxy" repository = "https://github.com/junkurihara/rust-rpxy"

View file

@ -29,7 +29,7 @@ rpxy-lib = { path = "../rpxy-lib/", default-features = false, features = [
mimalloc = { version = "*", default-features = false } mimalloc = { version = "*", default-features = false }
anyhow = "1.0.86" anyhow = "1.0.86"
rustc-hash = "1.1.0" rustc-hash = "2.0.0"
serde = { version = "1.0.203", default-features = false, features = ["derive"] } serde = { version = "1.0.203", default-features = false, features = ["derive"] }
tokio = { version = "1.38.0", default-features = false, features = [ tokio = { version = "1.38.0", default-features = false, features = [
"net", "net",

View file

@ -15,7 +15,7 @@ default = ["http3"]
http3 = [] http3 = []
[dependencies] [dependencies]
rustc-hash = { version = "1.1.0" } rustc-hash = { version = "2.0.0" }
tracing = { version = "0.1.40" } tracing = { version = "0.1.40" }
derive_builder = { version = "0.20.0" } derive_builder = { version = "0.20.0" }
thiserror = { version = "1.0.61" } thiserror = { version = "1.0.61" }

View file

@ -32,7 +32,7 @@ webpki-roots = ["rustls-backend", "hyper-rustls/webpki-tokio"]
[dependencies] [dependencies]
rand = "0.8.5" rand = "0.8.5"
rustc-hash = "1.1.0" rustc-hash = "2.0.0"
bytes = "1.6.0" bytes = "1.6.0"
derive_builder = "0.20.0" derive_builder = "0.20.0"
futures = { version = "0.3.30", features = ["alloc", "async-await"] } futures = { version = "0.3.30", features = ["alloc", "async-await"] }

View file

@ -31,12 +31,12 @@ macro_rules! ready {
type BodySender = mpsc::Sender<Result<Bytes, RpxyError>>; type BodySender = mpsc::Sender<Result<Bytes, RpxyError>>;
type TrailersSender = oneshot::Sender<HeaderMap>; type TrailersSender = oneshot::Sender<HeaderMap>;
const MAX_LEN: u64 = std::u64::MAX - 2; const MAX_LEN: u64 = u64::MAX - 2;
#[derive(Clone, Copy, PartialEq, Eq)] #[derive(Clone, Copy, PartialEq, Eq)]
pub(crate) struct DecodedLength(u64); pub(crate) struct DecodedLength(u64);
impl DecodedLength { impl DecodedLength {
pub(crate) const CLOSE_DELIMITED: DecodedLength = DecodedLength(::std::u64::MAX); pub(crate) const CLOSE_DELIMITED: DecodedLength = DecodedLength(u64::MAX);
pub(crate) const CHUNKED: DecodedLength = DecodedLength(::std::u64::MAX - 1); pub(crate) const CHUNKED: DecodedLength = DecodedLength(u64::MAX - 1);
pub(crate) const ZERO: DecodedLength = DecodedLength(0); pub(crate) const ZERO: DecodedLength = DecodedLength(0);
#[allow(dead_code)] #[allow(dead_code)]
@ -110,10 +110,7 @@ impl Body for IncomingLike {
type Data = Bytes; type Data = Bytes;
type Error = RpxyError; type Error = RpxyError;
fn poll_frame( fn poll_frame(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Result<Frame<Self::Data>, Self::Error>>> {
mut self: Pin<&mut Self>,
cx: &mut Context<'_>,
) -> Poll<Option<Result<Frame<Self::Data>, Self::Error>>> {
self.want_tx.send(WANT_READY); self.want_tx.send(WANT_READY);
if !self.data_rx.is_terminated() { if !self.data_rx.is_terminated() {
@ -156,10 +153,7 @@ impl Sender {
pub(crate) fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll<RpxyResult<()>> { pub(crate) fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll<RpxyResult<()>> {
// Check if the receiver end has tried polling for the body yet // Check if the receiver end has tried polling for the body yet
ready!(self.poll_want(cx)?); ready!(self.poll_want(cx)?);
self self.data_tx.poll_ready(cx).map_err(|_| RpxyError::HyperIncomingLikeNewClosed)
.data_tx
.poll_ready(cx)
.map_err(|_| RpxyError::HyperIncomingLikeNewClosed)
} }
fn poll_want(&mut self, cx: &mut Context<'_>) -> Poll<RpxyResult<()>> { fn poll_want(&mut self, cx: &mut Context<'_>) -> Poll<RpxyResult<()>> {
@ -256,11 +250,7 @@ mod tests {
assert_eq!(mem::size_of::<Sender>(), mem::size_of::<usize>() * 5, "Sender"); assert_eq!(mem::size_of::<Sender>(), mem::size_of::<usize>() * 5, "Sender");
assert_eq!( assert_eq!(mem::size_of::<Sender>(), mem::size_of::<Option<Sender>>(), "Option<Sender>");
mem::size_of::<Sender>(),
mem::size_of::<Option<Sender>>(),
"Option<Sender>"
);
} }
#[test] #[test]
fn size_hint() { fn size_hint() {