Skip to content

Commit

Permalink
fix(core): use default value for boxed body size_hint
Browse files Browse the repository at this point in the history
  • Loading branch information
fundon committed Dec 18, 2023
1 parent 6c26499 commit 80a8c56
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 12 deletions.
9 changes: 4 additions & 5 deletions viz-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,12 @@ futures-util.workspace = true

bytes.workspace = true
headers.workspace = true
http.workspace = true
http-body.workspace = true
http-body-util.workspace = true

hyper.workspace = true
http-body.workspace = true
http.workspace = true
hyper-util.workspace = true
sync_wrapper = { version = "0.1.2", git = "https://github.com/fundon/sync_wrapper.git", rev = "e2ce8d8" }
hyper.workspace = true
sync_wrapper = "0.1.2"

mime.workspace = true
thiserror.workspace = true
Expand Down
6 changes: 3 additions & 3 deletions viz-core/src/body.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,17 +173,17 @@ impl Body for OutgoingBody {
fn is_end_stream(&self) -> bool {
match self {
Self::Empty => true,
Self::Boxed(_) => false,
Self::Full(full) => full.is_end_stream(),
Self::Boxed(wrapper) => wrapper.get_ref().is_end_stream(),
}
}

#[inline]
fn size_hint(&self) -> SizeHint {
match self {
Self::Empty => SizeHint::with_exact(0),
Self::Boxed(_) => SizeHint::default(),
Self::Full(full) => full.size_hint(),
Self::Boxed(wrapper) => wrapper.get_ref().size_hint(),
}
}
}
Expand Down Expand Up @@ -212,8 +212,8 @@ impl Stream for OutgoingBody {
fn size_hint(&self) -> (usize, Option<usize>) {
let sh = match self {
Self::Empty => return (0, Some(0)),
Self::Boxed(_) => return (0, None),
Self::Full(full) => full.size_hint(),
Self::Boxed(wrapper) => wrapper.get_ref().size_hint(),
};
(
usize::try_from(sh.lower()).unwrap_or(usize::MAX),
Expand Down
6 changes: 2 additions & 4 deletions viz-core/src/handler/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ impl<S> ServiceHandler<S> {
impl<I, O, S> Handler<Request<I>> for ServiceHandler<S>
where
I: Body + Send + Unpin + 'static,
// O: Body + Send + 'static,
O: Body + Send + Sync + 'static,
O: Body + Send + 'static,
O::Data: Into<Bytes>,
O::Error: Into<Error>,
S: Service<Request<I>, Response = Response<O>> + Send + Sync + Clone + 'static,
Expand All @@ -38,8 +37,7 @@ where
resp.map(|body| {
body.map_frame(|f| f.map_data(Into::into))
.map_err(Into::into)
// .boxed_unsync()
.boxed()
.boxed_unsync()
})
.map(Into::into)
})
Expand Down

0 comments on commit 80a8c56

Please sign in to comment.