Struct StreamBody

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

An HttpBody implementation which handles data streaming in an efficient way.

It is similar to Body.

Implementations§

Source§

impl StreamBody

Source

pub fn empty() -> StreamBody

Creates an empty body.

Source

pub fn channel() -> (PipeWriter, StreamBody)

Creates a body stream with an associated writer half.

Useful when wanting to stream chunks from another thread.

Source

pub fn channel_with_capacity(capacity: usize) -> (PipeWriter, StreamBody)

Creates a body stream with an associated writer half having a specific size of internal buffer.

Useful when wanting to stream chunks from another thread.

Source

pub fn from_reader<R: AsyncRead + Unpin + Send + 'static>(r: R) -> StreamBody

A helper method to convert an AsyncRead to a StreamBody. If there is any error thrown during the reading/writing, it will be logged via log::error!.

Trait Implementations§

Source§

impl Body for StreamBody

Source§

type Data = StreamData

Values yielded by the Body.
Source§

type Error = Error

The error type this Body might generate.
Source§

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

Attempt to pull out the next data buffer of this stream.
Source§

fn poll_trailers( self: Pin<&mut Self>, _cx: &mut Context<'_>, ) -> Poll<Result<Option<HeaderMap<HeaderValue>>, Self::Error>>

Poll for an optional single HeaderMap of trailers. Read more
Source§

fn is_end_stream(&self) -> bool

Returns true when the end of stream has been reached. Read more
Source§

fn size_hint(&self) -> SizeHint

Returns the bounds on the remaining length of the stream. Read more
Source§

fn data(&mut self) -> Data<'_, Self>
where Self: Sized + Unpin,

Returns future that resolves to next data chunk, if any.
Source§

fn trailers(&mut self) -> Trailers<'_, Self>
where Self: Sized + Unpin,

Returns future that resolves to trailers, if any.
Source§

impl From<&'static [u8]> for StreamBody

Source§

fn from(slice: &'static [u8]) -> StreamBody

Converts to this type from the input type.
Source§

impl From<&'static str> for StreamBody

Source§

fn from(slice: &'static str) -> StreamBody

Converts to this type from the input type.
Source§

impl From<Bytes> for StreamBody

Source§

fn from(chunk: Bytes) -> StreamBody

Converts to this type from the input type.
Source§

impl From<Cow<'static, [u8]>> for StreamBody

Source§

fn from(cow: Cow<'static, [u8]>) -> StreamBody

Converts to this type from the input type.
Source§

impl From<Cow<'static, str>> for StreamBody

Source§

fn from(cow: Cow<'static, str>) -> StreamBody

Converts to this type from the input type.
Source§

impl From<String> for StreamBody

Source§

fn from(s: String) -> StreamBody

Converts to this type from the input type.
Source§

impl From<Vec<u8>> for StreamBody

Source§

fn from(vec: Vec<u8>) -> StreamBody

Converts to this type from the input type.

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> 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, 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.