#[non_exhaustive]pub struct Compression {
pub algos: IndexMap<CompressionAlgo, CompressionLevel>,
pub content_types: Vec<Mime>,
pub min_length: usize,
pub force_priority: bool,
}Expand description
Compression
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.algos: IndexMap<CompressionAlgo, CompressionLevel>Compression algorithms to use.
content_types: Vec<Mime>Content types to compress.
min_length: usizeMinimum body size to compress; bodies smaller than this value are not compressed.
This threshold only applies to bodies whose length is known up front
(in-memory Once/Chunks bodies). Streaming bodies (Hyper/Stream)
have no known length and are always compressed regardless of
min_length, so a tiny streamed body can still end up larger after
adding Content-Encoding and framing overhead.
force_priority: boolIgnore the client’s algorithm order in Accept-Encoding and always use the server’s
configured priority.
Implementations§
Source§impl Compression
impl Compression
Sourcepub fn disable_all(self) -> Self
pub fn disable_all(self) -> Self
Remove all compression algorithms.
Sourcepub fn enable_gzip(self, level: CompressionLevel) -> Self
Available on crate feature gzip only.
pub fn enable_gzip(self, level: CompressionLevel) -> Self
gzip only.Sets Compression with algos.
Sourcepub fn disable_gzip(self) -> Self
Available on crate feature gzip only.
pub fn disable_gzip(self) -> Self
gzip only.Disable gzip compression.
Sourcepub fn enable_zstd(self, level: CompressionLevel) -> Self
Available on crate feature zstd only.
pub fn enable_zstd(self, level: CompressionLevel) -> Self
zstd only.Enable zstd compression.
Sourcepub fn disable_zstd(self) -> Self
Available on crate feature zstd only.
pub fn disable_zstd(self) -> Self
zstd only.Disable zstd compression.
Sourcepub fn enable_brotli(self, level: CompressionLevel) -> Self
Available on crate feature brotli only.
pub fn enable_brotli(self, level: CompressionLevel) -> Self
brotli only.Enable brotli compression.
Sourcepub fn disable_brotli(self) -> Self
Available on crate feature brotli only.
pub fn disable_brotli(self) -> Self
brotli only.Disable brotli compression.
Sourcepub fn enable_deflate(self, level: CompressionLevel) -> Self
Available on crate feature deflate only.
pub fn enable_deflate(self, level: CompressionLevel) -> Self
deflate only.Enable deflate compression.
Sourcepub fn disable_deflate(self) -> Self
Available on crate feature deflate only.
pub fn disable_deflate(self) -> Self
deflate only.Disable deflate compression.
Sourcepub fn min_length(self, size: usize) -> Self
pub fn min_length(self, size: usize) -> Self
Sets minimum compression size, if body is less than this value, no compression. Default is 1kb.
Only effective for bodies with a known length (Once/Chunks); streaming
bodies (Hyper/Stream) are always compressed regardless of this value.
Sourcepub fn force_priority(self, force_priority: bool) -> Self
pub fn force_priority(self, force_priority: bool) -> Self
Sets Compression with force_priority.
Sourcepub fn content_types(self, content_types: &[Mime]) -> Self
pub fn content_types(self, content_types: &[Mime]) -> Self
Sets Compression with content types list.
Trait Implementations§
Source§impl Clone for Compression
impl Clone for Compression
Source§fn clone(&self) -> Compression
fn clone(&self) -> Compression
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for Compression
impl Debug for Compression
Source§impl Default for Compression
impl Default for Compression
Source§impl Handler for Compression
impl Handler for Compression
Source§fn handle<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>(
&'life0 self,
req: &'life1 mut Request,
depot: &'life2 mut Depot,
res: &'life3 mut Response,
ctrl: &'life4 mut FlowCtrl,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
'life4: 'async_trait,
fn handle<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>(
&'life0 self,
req: &'life1 mut Request,
depot: &'life2 mut Depot,
res: &'life3 mut Response,
ctrl: &'life4 mut FlowCtrl,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
'life4: 'async_trait,
Source§fn arc(self) -> ArcHandlerwhere
Self: Sized,
fn arc(self) -> ArcHandlerwhere
Self: Sized,
ArcHandler.Source§fn hooped(self) -> HoopedHandlerwhere
Self: Sized,
fn hooped(self) -> HoopedHandlerwhere
Self: Sized,
HoopedHandler.