Skip to main content

Remaining

Enum Remaining 

Source
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:

§Invariants

  • Body(stream): The stream has not ended and may yield more frames
  • Error(Some(e)): An error occurred; will be yielded once then become None
  • Error(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§

Source§

impl<B> Debug for Remaining<B>
where B: HttpBody + Debug, B::Error: Debug,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'pin, B> Unpin for Remaining<B>
where B: HttpBody, PinnedFieldsOf<__Remaining<'pin, B>>: Unpin,

Auto Trait Implementations§

§

impl<B> Freeze for Remaining<B>
where B: Freeze, <B as Body>::Error: Freeze,

§

impl<B> RefUnwindSafe for Remaining<B>

§

impl<B> Send for Remaining<B>
where B: Send, <B as Body>::Error: Send,

§

impl<B> Sync for Remaining<B>
where B: Sync, <B as Body>::Error: Sync,

§

impl<B> UnwindSafe for Remaining<B>
where B: UnwindSafe, <B as Body>::Error: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more