Skip to content

Commit

Permalink
axum-core/body: Implement Stream::size_hint for BodyDataStream (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
ikrivosheev authored Jan 24, 2025
1 parent 0cb6865 commit b0b8174
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions axum-core/src/body.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,14 @@ impl Stream for BodyDataStream {
}
}
}

#[inline]
fn size_hint(&self) -> (usize, Option<usize>) {
let size_hint = self.inner.size_hint();
let lower = usize::try_from(size_hint.lower()).unwrap_or_default();
let upper = size_hint.upper().and_then(|v| usize::try_from(v).ok());
(lower, upper)
}
}

impl http_body::Body for BodyDataStream {
Expand Down

0 comments on commit b0b8174

Please sign in to comment.