diff --git a/http/CHANGES.md b/http/CHANGES.md index e578793f..664f5660 100644 --- a/http/CHANGES.md +++ b/http/CHANGES.md @@ -1,4 +1,6 @@ -# unreleased +# unreleased 0.4.0 +## Change +- `body::Either` doesn't expose it's enum variants in public API anymore. # 0.3.0 ## Add diff --git a/http/Cargo.toml b/http/Cargo.toml index 94cf190e..b5b4ac58 100644 --- a/http/Cargo.toml +++ b/http/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "xitca-http" -version = "0.3.0" +version = "0.4.0" edition = "2021" license = "Apache-2.0" description = "http library for xitca" diff --git a/http/src/body.rs b/http/src/body.rs index 776c7de8..69cab77d 100644 --- a/http/src/body.rs +++ b/http/src/body.rs @@ -166,18 +166,25 @@ where Poll::Ready(mem::replace(self.get_mut(), Self(None)).0.map(Ok)) } - // use the length of buffer as both lower bound and upperbound. + // use the length of buffer as both lower bound and upper bound. fn size_hint(&self) -> (usize, Option) { - match self.0 { - Some(ref b) => exact_body_hint(b.remaining()), - None => unreachable!("Once must check size_hint before it got polled"), - } + self.0 + .as_ref() + .map(|b| exact_body_hint(b.remaining())) + .expect("Once must check size_hint before it got polled") + } +} + +pin_project! { + pub struct Either { + #[pin] + inner: EitherInner } } pin_project! { #[project = EitherProj] - pub enum Either { + enum EitherInner { L { #[pin] inner: L @@ -192,12 +199,16 @@ pin_project! { impl Either { #[inline] pub const fn left(inner: L) -> Self { - Self::L { inner } + Self { + inner: EitherInner::L { inner }, + } } #[inline] pub const fn right(inner: R) -> Self { - Self::R { inner } + Self { + inner: EitherInner::R { inner }, + } } } @@ -211,7 +222,7 @@ where #[inline] fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll> { - match self.project() { + match self.project().inner.project() { EitherProj::L { inner } => inner.poll_next(cx).map(|res| res.map(|res| res.map_err(Into::into))), EitherProj::R { inner } => inner.poll_next(cx), } @@ -219,9 +230,9 @@ where #[inline] fn size_hint(&self) -> (usize, Option) { - match *self { - Self::L { ref inner } => inner.size_hint(), - Self::R { ref inner } => inner.size_hint(), + match self.inner { + EitherInner::L { ref inner } => inner.size_hint(), + EitherInner::R { ref inner } => inner.size_hint(), } } } diff --git a/web/CHANGES.md b/web/CHANGES.md index bb7fed8b..3c198708 100644 --- a/web/CHANGES.md +++ b/web/CHANGES.md @@ -1,4 +1,6 @@ -# unreleased +# unreleased 0.4.0 +## Change +- update `xitca-http` to `0.4.0` # 0.3.0 ## Add diff --git a/web/Cargo.toml b/web/Cargo.toml index f180b5bc..149000dd 100644 --- a/web/Cargo.toml +++ b/web/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "xitca-web" -version = "0.3.0" +version = "0.4.0" edition = "2021" license = "Apache-2.0" description = "an async web framework" @@ -76,7 +76,7 @@ serde = ["dep:serde"] __server = ["xitca-http/runtime", "xitca-server"] [dependencies] -xitca-http = { version = "0.3.0", features = ["router"], default-features = false } +xitca-http = { version = "0.4.0", features = ["router"], default-features = false } xitca-service = { version = "0.1", features = ["alloc", "std"] } xitca-unsafe-collection = "0.1"