#[non_exhaustive]pub struct MessageConfig { /* private fields */ }Expand description
Settings for one direction of a permessage-deflate connection.
| Setting | Default | RFC 7692 parameter |
|---|---|---|
| window bits | 15 | server_max_window_bits / client_max_window_bits |
| context takeover | off | server_no_context_takeover / client_no_context_takeover absent |
| level | 1 | (local choice) |
Memory per direction: without takeover a Decompressor holds only its
decode tables (about 11 KiB, no window); with takeover it adds the window
(2^window_bits bytes). A Compressor holds a deflater sized by the
window bits (about 270 KiB at 15, under 100 KiB at 9).
§Examples
use compress_lib::{Level, message::MessageConfig};
let config = MessageConfig::new().with_window_bits(10).with_context_takeover(true).with_level(Level::DEFAULT);
assert_eq!(config.window_bits(), 10);
assert!(config.context_takeover());Implementations§
Source§impl MessageConfig
impl MessageConfig
Sourcepub const fn new() -> Self
pub const fn new() -> Self
Window bits 15, no context takeover, level 1.
§Examples
use compress_lib::message::MessageConfig;
assert_eq!(MessageConfig::new(), MessageConfig::default());
assert!(!MessageConfig::new().context_takeover());Sourcepub const fn with_window_bits(self, bits: u8) -> Self
pub const fn with_window_bits(self, bits: u8) -> Self
Sets the window bits, 8 to 15 (checked when an engine is built).
§Examples
assert_eq!(compress_lib::message::MessageConfig::new().with_window_bits(9).window_bits(), 9);Sourcepub const fn with_context_takeover(self, on: bool) -> Self
pub const fn with_context_takeover(self, on: bool) -> Self
Keeps the window from one message to the next.
§Examples
assert!(compress_lib::message::MessageConfig::new().with_context_takeover(true).context_takeover());Sourcepub const fn with_level(self, level: Level) -> Self
pub const fn with_level(self, level: Level) -> Self
Sets the compression level (the compressor only).
§Examples
use compress_lib::{Level, message::MessageConfig};
assert_eq!(MessageConfig::new().with_level(Level::BEST).level(), Level::BEST);Sourcepub const fn with_memory(self, memory: MemoryConfig) -> Self
pub const fn with_memory(self, memory: MemoryConfig) -> Self
Sizes the compressor’s hash table and symbol buffer (see
MemoryConfig); the decompressor is not affected.
§Examples
use compress_lib::{deflate::MemoryConfig, message::MessageConfig};
let config = MessageConfig::new().with_memory(MemoryConfig::new().with_hash_bits(10));
assert_eq!(config.memory().hash_bits(), 10);Sourcepub const fn memory(&self) -> MemoryConfig
pub const fn memory(&self) -> MemoryConfig
The compressor’s memory settings.
§Examples
assert_eq!(compress_lib::message::MessageConfig::new().memory().hash_bits(), 0);Sourcepub const fn window_bits(&self) -> u8
pub const fn window_bits(&self) -> u8
The window bits.
§Examples
assert_eq!(compress_lib::message::MessageConfig::new().window_bits(), 15);Sourcepub const fn context_takeover(&self) -> bool
pub const fn context_takeover(&self) -> bool
Whether the window carries over between messages.
§Examples
assert!(!compress_lib::message::MessageConfig::new().context_takeover());Trait Implementations§
Source§impl Clone for MessageConfig
impl Clone for MessageConfig
impl Copy for MessageConfig
Source§impl Debug for MessageConfig
impl Debug for MessageConfig
Source§impl Default for MessageConfig
impl Default for MessageConfig
impl Eq for MessageConfig
Source§impl Hash for MessageConfig
impl Hash for MessageConfig
Source§impl PartialEq for MessageConfig
impl PartialEq for MessageConfig
impl StructuralPartialEq for MessageConfig
Auto Trait Implementations§
impl Forget for MessageConfig
impl Freeze for MessageConfig
impl RefUnwindSafe for MessageConfig
impl Send for MessageConfig
impl Sync for MessageConfig
impl Unpin for MessageConfig
impl UnsafeUnpin for MessageConfig
impl UnwindSafe for MessageConfig
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