CompressionBody

Enum CompressionBody 

Source
pub enum CompressionBody<B> {
    Compressed {
        inner: B,
        state: CompressedBody,
    },
    Passthrough {
        inner: B,
    },
}
Expand description

A response body that may be compressed.

This type wraps an inner body and either compresses it using the specified codec or passes it through unchanged.

Variants§

§

Compressed

Compressed body with encoder.

Fields

§inner: B
§state: CompressedBody
§

Passthrough

Passthrough body without compression.

Fields

§inner: B

Implementations§

Source§

impl<B> CompressionBody<B>

Source

pub fn compressed(inner: B, codec: Codec, always_flush: bool) -> Self

Creates a compressed body with the given codec.

Source

pub fn passthrough(inner: B) -> Self

Creates a passthrough body without compression.

Trait Implementations§

Source§

impl<B> Body for CompressionBody<B>
where B: Body, B::Data: Buf, B::Error: Into<Box<dyn Error + Send + Sync>>,

Source§

type Data = Bytes

Values yielded by the Body.
Source§

type Error = Error

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 data buffer of this stream.
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§

impl<'__pin, B> Unpin for CompressionBody<B>
where PinnedFieldsOf<__Origin<'__pin, B>>: Unpin,

Auto Trait Implementations§

§

impl<B> Freeze for CompressionBody<B>
where B: Freeze,

§

impl<B> !RefUnwindSafe for CompressionBody<B>

§

impl<B> Send for CompressionBody<B>
where B: Send,

§

impl<B> !Sync for CompressionBody<B>

§

impl<B> !UnwindSafe for CompressionBody<B>

Blanket Implementations§

§

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

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

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

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

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

§

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

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

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

§

fn into(self) -> U

Calls U::from(self).

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

§

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

§

type Error = Infallible

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

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

Performs the conversion.
§

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

§

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

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

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

Performs the conversion.