Struct tower_http::compression::CompressionLayer
source · [−]pub struct CompressionLayer<P = DefaultPredicate> { /* private fields */ }compression-br or compression-deflate or compression-gzip only.Expand description
Compress response bodies of the underlying service.
This uses the Accept-Encoding header to pick an appropriate encoding and adds the
Content-Encoding header to responses.
See the module docs for more details.
Implementations
sourceimpl CompressionLayer
impl CompressionLayer
sourcepub fn new() -> Self
pub fn new() -> Self
Create a new CompressionLayer
sourcepub fn gzip(self, enable: bool) -> Self
Available on crate feature compression-gzip only.
pub fn gzip(self, enable: bool) -> Self
compression-gzip only.Sets whether to enable the gzip encoding.
sourcepub fn deflate(self, enable: bool) -> Self
Available on crate feature compression-deflate only.
pub fn deflate(self, enable: bool) -> Self
compression-deflate only.Sets whether to enable the Deflate encoding.
sourcepub fn br(self, enable: bool) -> Self
Available on crate feature compression-br only.
pub fn br(self, enable: bool) -> Self
compression-br only.Sets whether to enable the Brotli encoding.
sourcepub fn no_gzip(self) -> Self
pub fn no_gzip(self) -> Self
Disables the gzip encoding.
This method is available even if the gzip crate feature is disabled.
sourcepub fn no_deflate(self) -> Self
pub fn no_deflate(self) -> Self
Disables the Deflate encoding.
This method is available even if the deflate crate feature is disabled.
sourcepub fn no_br(self) -> Self
pub fn no_br(self) -> Self
Disables the Brotli encoding.
This method is available even if the br crate feature is disabled.
sourcepub fn compress_when<C>(self, predicate: C) -> CompressionLayer<C> where
C: Predicate,
pub fn compress_when<C>(self, predicate: C) -> CompressionLayer<C> where
C: Predicate,
Replace the current compression predicate.
See Compression::compress_when for more details.
Trait Implementations
sourceimpl<P: Clone> Clone for CompressionLayer<P>
impl<P: Clone> Clone for CompressionLayer<P>
sourcefn clone(&self) -> CompressionLayer<P>
fn clone(&self) -> CompressionLayer<P>
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source. Read more
sourceimpl<P: Debug> Debug for CompressionLayer<P>
impl<P: Debug> Debug for CompressionLayer<P>
sourceimpl<P: Default> Default for CompressionLayer<P>
impl<P: Default> Default for CompressionLayer<P>
sourcefn default() -> CompressionLayer<P>
fn default() -> CompressionLayer<P>
Returns the “default value” for a type. Read more
sourceimpl<S, P> Layer<S> for CompressionLayer<P> where
P: Predicate,
impl<S, P> Layer<S> for CompressionLayer<P> where
P: Predicate,
Auto Trait Implementations
impl<P> RefUnwindSafe for CompressionLayer<P> where
P: RefUnwindSafe,
impl<P> Send for CompressionLayer<P> where
P: Send,
impl<P> Sync for CompressionLayer<P> where
P: Sync,
impl<P> Unpin for CompressionLayer<P> where
P: Unpin,
impl<P> UnwindSafe for CompressionLayer<P> where
P: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> PolicyExt for T where
T: ?Sized,
impl<T> PolicyExt for T where
T: ?Sized,
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into)Uses borrowed data to replace owned data, usually by cloning. Read more
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
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
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber to this type, returning a
WithDispatch wrapper. Read more