pub struct BlockSize(/* private fields */);
Expand description
The recommended input block size (in bits) to use for compression.
The compressor may reduce this value at its leisure, for example when the
input size is small. Larger block sizes allow better compression at the
expense of using more memory. Rough formula for memory required is 3 << bits
bytes.
Implementations§
Source§impl BlockSize
impl BlockSize
Sourcepub const fn new(bits: u8) -> Result<BlockSize, SetParameterError>
pub const fn new(bits: u8) -> Result<BlockSize, SetParameterError>
Constructs a new block size (in bits) to use for brotli compression.
Valid bits
range from 16 to 24 inclusive.
§Errors
An Err
will be returned if the bits
are out of the range of valid
block sizes.
§Examples
use brotlic::BlockSize;
let worst_size = BlockSize::new(16)?;
let best_size = BlockSize::new(24)?;
assert_eq!(worst_size, BlockSize::worst());
assert_eq!(best_size, BlockSize::best());
Sourcepub const fn new_unchecked(bits: u8) -> BlockSize
pub const fn new_unchecked(bits: u8) -> BlockSize
Constructs a new block size (in bits) to use for brotli compression.
Valid bits
range from 16 to 24 inclusive. Using any number of bits
outside of that range results in undefined behaviour.
§Safety
The number of bits
must be between 16 and 24.
§Examples
use brotlic::BlockSize;
let block_size = unsafe { BlockSize::new_unchecked(22) };
assert_eq!(block_size.bits(), 22);
Sourcepub const fn best() -> BlockSize
pub const fn best() -> BlockSize
Constructs the best block size (in bits) to use for brotli compression.
This will allow better compression at the expense of memory usage. Currently it is set to 24 bits.
§Examples
use brotlic::BlockSize;
let best_size = BlockSize::new(24)?;
assert_eq!(best_size, BlockSize::best());
Sourcepub const fn worst() -> BlockSize
pub const fn worst() -> BlockSize
Constructs the worst block size (in bits) to use for brotli compression.
This will consume the least amount of memory at the expense of compression ratio. Currently it is set to 16 bits.
§Examples
use brotlic::BlockSize;
let worst_size = BlockSize::new(16)?;
assert_eq!(worst_size, BlockSize::worst());