Skip to main content

IncomingBody

Struct IncomingBody 

Source
pub struct IncomingBody<T> { /* private fields */ }
Expand description

A stream of Bytes, used when receiving bodies from the network.

Implementations§

Source§

impl<T: IncomingMessage> IncomingBody<T>

Source

pub fn new(msg: T) -> Result<Self, ErrorCode>

Creates a new IncomingBody from the given incoming message.

This initializes the body in an unstarted state and extracts the Content-Length header if present. The resulting instance can later transition into a streaming or consumed state.

Returns an ErrorCode if the content length is invalid or cannot be determined.

Source

pub fn take_unstarted(&mut self) -> Option<T>

Takes ownership of the inner message if the body has not yet been started.

This method replaces the internal state with [StartedState::Empty] and returns the contained message if it was still in the unstarted state. Returns None otherwise.

Trait Implementations§

Source§

impl<T: IncomingMessage> Body for IncomingBody<T>

Source§

type Data = Bytes

Values yielded by the Body.
Source§

type Error = ErrorCode

The error type this Body might generate.
Source§

fn poll_frame( self: Pin<&mut Self>, cx: &mut Context<'_>, ) -> Poll<Option<Result<Frame<Self::Data>, Self::Error>>>

Attempt to pull out the next frame of this stream. Read more
Source§

fn is_end_stream(&self) -> bool

A hint that may return true when the end of stream has been reached. Read more
Source§

fn size_hint(&self) -> SizeHint

A hint that returns the bounds on the remaining length of the stream. Read more

Auto Trait Implementations§

§

impl<T> !Freeze for IncomingBody<T>

§

impl<T> !RefUnwindSafe for IncomingBody<T>

§

impl<T> !Sync for IncomingBody<T>

§

impl<T> !UnwindSafe for IncomingBody<T>

§

impl<T> Send for IncomingBody<T>
where StartedState<T>: Send,

§

impl<T> Unpin for IncomingBody<T>
where StartedState<T>: Unpin,

§

impl<T> UnsafeUnpin for IncomingBody<T>
where StartedState<T>: UnsafeUnpin,

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, 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> Resource for T
where T: 'static,

Source§

type Rep = Option<T>

The type which is actually stored in-memory for this resource. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.