pub enum Remaining<B>where
B: HttpBody,{
Body(B),
Error(Option<B::Error>),
}Expand description
What remains of a body stream after partial consumption.
When predicates or extractors read bytes from a body, the stream may have more data available or may have encountered an error. This enum captures both possibilities, preserving the stream state for forwarding to upstream.
§When You’ll Encounter This
You typically don’t create this directly. It appears when:
- Using
BufferedBody::collect_exactwhich returns remaining stream data - Decomposing a
PartialBufferedBodyviainto_parts
§Invariants
Body(stream): The stream has not ended and may yield more framesError(Some(e)): An error occurred; will be yielded once then becomeNoneError(None): Error was already yielded; stream is terminated
§Examples
use hitbox_http::{BufferedBody, CollectExactResult, Remaining};
async fn example<B: hyper::body::Body + Unpin>(body: BufferedBody<B>) {
// After collecting 100 bytes from a larger body
let result = body.collect_exact(100).await;
match result {
CollectExactResult::AtLeast { buffered, remaining } => {
match remaining {
Some(Remaining::Body(stream)) => {
// More data available in stream
}
Some(Remaining::Error(err)) => {
// Error occurred after collecting bytes
}
None => {
// Stream ended exactly at limit
}
}
}
CollectExactResult::Incomplete { .. } => {}
}
}Variants§
Body(B)
The body stream continues with unconsumed data.
Error(Option<B::Error>)
An error occurred during consumption.
The Option allows the error to be yielded once, then None on
subsequent polls.
Trait Implementations§
Auto Trait Implementations§
impl<B> Freeze for Remaining<B>
impl<B> RefUnwindSafe for Remaining<B>
impl<B> Send for Remaining<B>
impl<B> Sync for Remaining<B>
impl<B> UnwindSafe for Remaining<B>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more