Skip to main content

StreamingBody

Struct StreamingBody 

Source
pub struct StreamingBody { /* private fields */ }
Expand description

Typed streaming HTTP response body.

exact_length is optional. HTTP/1 uses chunked transfer coding when it is absent, while HTTP/2 emits DATA frames without a content-length field.

Implementations§

Source§

impl StreamingBody

Source

pub fn new(stream: impl BodyStream) -> Self

Source

pub fn from_chunks<I, Chunk>(chunks: I) -> Self
where I: IntoIterator<Item = Chunk>, I::IntoIter: Unpin + 'static, Chunk: Into<Vec<u8>> + 'static,

Builds a pull stream from already available chunks.

Source

pub fn once(bytes: impl Into<Vec<u8>>) -> Self

Builds a one-chunk stream with a known exact length.

Source

pub const fn with_exact_length(self, length: u64) -> Self

Source

pub const fn exact_length(&self) -> Option<u64>

Source

pub async fn next_chunk(&mut self) -> Option<Result<Vec<u8>, BodyStreamError>>

Waits until the producer yields one chunk.

Calling this method is the consumer demand signal. Transports should not request another chunk until the previous one has been written.

Source

pub fn recycle(&mut self, spent: Vec<u8>)

Hands a spent chunk’s buffer back to the producer for reuse.

See BodyStream::recycle; producers that do not reuse buffers simply drop it.

Trait Implementations§

Source§

impl ApiSchema for StreamingBody

Source§

fn type_descriptor() -> TypeDescriptor

Source§

fn validate_input(&self) -> Result<(), ValidationErrors>

Validates a decoded operation argument. Read more
Source§

impl Debug for StreamingBody

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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> BackgroundExt for T

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> ResponseExt for T

Source§

fn header( self, name: impl Into<String>, value: impl Into<String>, ) -> WithHeaders<Self>

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.