#[non_exhaustive]pub struct MemoryConfig { /* private fields */ }Expand description
Memory settings for a Deflater: the hash table and the symbol
buffer, the two largest parts after the window.
| Setting | Default | Memory | Effect |
|---|---|---|---|
| hash bits | window bits + 1, 9 to 15 (12 at most at level 1) | 2 bytes per entry | fewer bits: less memory, more collisions, slightly larger output |
| block symbols | 2^(window bits + 1), 1,024 to 16,384 | 4 bytes per symbol, plus up to 4 bytes of pending output | fewer: less memory, more block headers |
§Examples
use compress_lib::deflate::MemoryConfig;
let config = MemoryConfig::new().with_hash_bits(11).with_block_symbols(4096);
assert_eq!((config.hash_bits(), config.block_symbols()), (11, 4096));Implementations§
Source§impl MemoryConfig
impl MemoryConfig
Sourcepub const fn new() -> Self
pub const fn new() -> Self
Both sizes chosen from the window bits.
§Examples
assert_eq!(compress_lib::deflate::MemoryConfig::new().hash_bits(), 0);Sourcepub const fn with_hash_bits(self, bits: u8) -> Self
pub const fn with_hash_bits(self, bits: u8) -> Self
Sets the hash table to 2^bits entries; clamped to 8 to 16 (0 keeps
the default).
§Examples
assert_eq!(compress_lib::deflate::MemoryConfig::new().with_hash_bits(20).hash_bits(), 16);Sourcepub const fn with_block_symbols(self, symbols: usize) -> Self
pub const fn with_block_symbols(self, symbols: usize) -> Self
Sets the symbols per block; clamped to 256 to 65,536 (0 keeps the default).
§Examples
assert_eq!(compress_lib::deflate::MemoryConfig::new().with_block_symbols(100).block_symbols(), 256);Sourcepub const fn hash_bits(&self) -> u8
pub const fn hash_bits(&self) -> u8
The hash bits set (0: chosen from the window bits).
§Examples
assert_eq!(compress_lib::deflate::MemoryConfig::new().with_hash_bits(10).hash_bits(), 10);Sourcepub const fn block_symbols(&self) -> usize
pub const fn block_symbols(&self) -> usize
The symbols per block set (0: chosen from the window bits).
§Examples
assert_eq!(compress_lib::deflate::MemoryConfig::new().block_symbols(), 0);Trait Implementations§
Source§impl Clone for MemoryConfig
impl Clone for MemoryConfig
impl Copy for MemoryConfig
Source§impl Debug for MemoryConfig
impl Debug for MemoryConfig
Source§impl Default for MemoryConfig
impl Default for MemoryConfig
impl Eq for MemoryConfig
Source§impl Hash for MemoryConfig
impl Hash for MemoryConfig
Source§impl PartialEq for MemoryConfig
impl PartialEq for MemoryConfig
impl StructuralPartialEq for MemoryConfig
Auto Trait Implementations§
impl Forget for MemoryConfig
impl Freeze for MemoryConfig
impl RefUnwindSafe for MemoryConfig
impl Send for MemoryConfig
impl Sync for MemoryConfig
impl Unpin for MemoryConfig
impl UnsafeUnpin for MemoryConfig
impl UnwindSafe for MemoryConfig
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