#[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
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional
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: usize
Sets minimum compression size, if body is less than this value, no compression.
force_priority: bool
Ignore request algorithms order in Accept-Encoding
header and always server’s config.
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
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
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
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,
Handle http request.
Source§fn arc(self) -> ArcHandlerwhere
Self: Sized,
fn arc(self) -> ArcHandlerwhere
Self: Sized,
Wrap to
ArcHandler
.Source§fn hoop<H>(self, hoop: H) -> HoopedHandler
fn hoop<H>(self, hoop: H) -> HoopedHandler
Hoop this handler with middleware.
Auto Trait Implementations§
impl Freeze for Compression
impl RefUnwindSafe for Compression
impl Send for Compression
impl Sync for Compression
impl Unpin for Compression
impl UnwindSafe for Compression
Blanket Implementations§
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
Mutably borrows from an owned value. Read more