pub struct ResponseCompression(/* private fields */);Expand description
HTTP response compression module
Methods from Deref<Target = ResponseCompressionCtx>§
Sourcepub fn is_enabled(&self) -> bool
pub fn is_enabled(&self) -> bool
Whether the encoder is enabled. The enablement will change according to the request and response filter by this ctx.
Sourcepub fn get_info(&self) -> Option<(&'static str, usize, usize, Duration)>
pub fn get_info(&self) -> Option<(&'static str, usize, usize, Duration)>
Return the stat of this ctx: algorithm name, in bytes, out bytes, time took for the compression
Sourcepub fn adjust_level(&mut self, new_level: u32)
pub fn adjust_level(&mut self, new_level: u32)
Adjust the compression level for all compression algorithms.
§Panic
This function will panic if it has already started encoding the response body.
Sourcepub fn adjust_algorithm_level(&mut self, algorithm: Algorithm, new_level: u32)
pub fn adjust_algorithm_level(&mut self, algorithm: Algorithm, new_level: u32)
Adjust the compression level for a specific algorithm.
§Panic
This function will panic if it has already started encoding the response body.
Sourcepub fn adjust_decompression(&mut self, enabled: bool)
pub fn adjust_decompression(&mut self, enabled: bool)
Adjust the decompression flag for all compression algorithms.
§Panic
This function will panic if it has already started encoding the response body.
Sourcepub fn adjust_algorithm_decompression(
&mut self,
algorithm: Algorithm,
enabled: bool,
)
pub fn adjust_algorithm_decompression( &mut self, algorithm: Algorithm, enabled: bool, )
Adjust the decompression flag for a specific algorithm.
§Panic
This function will panic if it has already started encoding the response body.
Sourcepub fn adjust_preserve_etag(&mut self, enabled: bool)
pub fn adjust_preserve_etag(&mut self, enabled: bool)
Adjust preserve etag setting.
§Panic
This function will panic if it has already started encoding the response body.
Sourcepub fn adjust_algorithm_preserve_etag(
&mut self,
algorithm: Algorithm,
enabled: bool,
)
pub fn adjust_algorithm_preserve_etag( &mut self, algorithm: Algorithm, enabled: bool, )
Adjust preserve etag setting for a specific algorithm.
§Panic
This function will panic if it has already started encoding the response body.
Sourcepub fn request_filter(&mut self, req: &RequestHeader)
pub fn request_filter(&mut self, req: &RequestHeader)
Feed the request header into this ctx.
Sourcepub fn response_header_filter(&mut self, resp: &mut ResponseHeader, end: bool)
pub fn response_header_filter(&mut self, resp: &mut ResponseHeader, end: bool)
Feed the response header into this ctx
Sourcepub fn response_body_filter(
&mut self,
data: Option<&Bytes>,
end: bool,
) -> Option<Bytes>
pub fn response_body_filter( &mut self, data: Option<&Bytes>, end: bool, ) -> Option<Bytes>
Stream the response body chunks into this ctx. The return value will be the compressed data.
Return None if compression is not enabled.
Sourcepub fn response_filter(&mut self, t: &mut HttpTask)
pub fn response_filter(&mut self, t: &mut HttpTask)
Feed the response into this ctx. This filter will mutate the response accordingly if encoding is needed.
Trait Implementations§
Source§impl Deref for ResponseCompression
impl Deref for ResponseCompression
Source§type Target = ResponseCompressionCtx
type Target = ResponseCompressionCtx
Source§impl DerefMut for ResponseCompression
impl DerefMut for ResponseCompression
Source§impl HttpModule for ResponseCompression
impl HttpModule for ResponseCompression
fn as_any(&self) -> &(dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn request_header_filter<'life0, 'life1, 'async_trait>(
&'life0 mut self,
req: &'life1 mut RequestHeader,
) -> Pin<Box<dyn Future<Output = Result<(), Box<Error>>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
ResponseCompression: 'async_trait,
fn response_header_filter<'life0, 'life1, 'async_trait>(
&'life0 mut self,
resp: &'life1 mut ResponseHeader,
end_of_stream: bool,
) -> Pin<Box<dyn Future<Output = Result<(), Box<Error>>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
ResponseCompression: 'async_trait,
fn response_body_filter( &mut self, body: &mut Option<Bytes>, end_of_stream: bool, ) -> Result<(), Box<Error>>
fn response_done_filter(&mut self) -> Result<Option<Bytes>, Box<Error>>
fn request_body_filter<'life0, 'life1, 'async_trait>(
&'life0 mut self,
_body: &'life1 mut Option<Bytes>,
_end_of_stream: bool,
) -> Pin<Box<dyn Future<Output = Result<(), Box<Error>>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: Send + 'async_trait,
fn response_trailer_filter( &mut self, _trailers: &mut Option<Box<HeaderMap>>, ) -> Result<Option<Bytes>, Box<Error>>
Auto Trait Implementations§
impl Freeze for ResponseCompression
impl !RefUnwindSafe for ResponseCompression
impl Send for ResponseCompression
impl Sync for ResponseCompression
impl Unpin for ResponseCompression
impl !UnwindSafe for ResponseCompression
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out indicating that a T is niched.