pub struct CompressionConfig {
pub enabled: bool,
pub level: CompressionLevel,
pub algorithms: Vec<CompressionAlgorithm>,
pub min_size: usize,
pub max_size: Option<usize>,
pub mime_types: Vec<String>,
pub compress_requests: bool,
pub compress_responses: bool,
pub buffer_size: usize,
}Expand description
Compression configuration
Fields§
§enabled: boolEnable compression
level: CompressionLevelDefault compression level
algorithms: Vec<CompressionAlgorithm>Supported algorithms (in order of preference)
min_size: usizeMinimum size in bytes to compress (don’t compress small responses)
max_size: Option<usize>Maximum size in bytes to compress (avoid compressing huge responses)
mime_types: Vec<String>MIME types to compress
compress_requests: boolEnable compression for requests
compress_responses: boolEnable compression for responses
buffer_size: usizeBuffer size for streaming compression
Implementations§
Source§impl CompressionConfig
impl CompressionConfig
Sourcepub fn production() -> Self
pub fn production() -> Self
Create a production configuration
Sourcepub fn development() -> Self
pub fn development() -> Self
Create a development configuration
Sourcepub fn high_compression() -> Self
pub fn high_compression() -> Self
Create a high compression configuration
Sourcepub fn should_compress_mime_type(&self, content_type: &str) -> bool
pub fn should_compress_mime_type(&self, content_type: &str) -> bool
Check if content type should be compressed
Sourcepub fn should_compress_size(&self, size: usize) -> bool
pub fn should_compress_size(&self, size: usize) -> bool
Check if size should be compressed
Sourcepub fn select_algorithm(
&self,
accept_encoding: Option<&str>,
) -> Option<CompressionAlgorithm>
pub fn select_algorithm( &self, accept_encoding: Option<&str>, ) -> Option<CompressionAlgorithm>
Select best algorithm from Accept-Encoding header
Trait Implementations§
Source§impl Clone for CompressionConfig
impl Clone for CompressionConfig
Source§fn clone(&self) -> CompressionConfig
fn clone(&self) -> CompressionConfig
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 CompressionConfig
impl Debug for CompressionConfig
Source§impl Default for CompressionConfig
impl Default for CompressionConfig
Source§impl<'de> Deserialize<'de> for CompressionConfig
impl<'de> Deserialize<'de> for CompressionConfig
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for CompressionConfig
impl RefUnwindSafe for CompressionConfig
impl Send for CompressionConfig
impl Sync for CompressionConfig
impl Unpin for CompressionConfig
impl UnwindSafe for CompressionConfig
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
Converts
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>
Converts
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 more