pub struct BrotliEncoderOptions { /* private fields */ }
Expand description
Compression options to be used for a BrotliEncoder
.
§Examples
Building an encoder using text mode and use a custom quality:
use brotlic::{BrotliEncoderOptions, CompressionMode, Quality};
let encoder = BrotliEncoderOptions::new()
.mode(CompressionMode::Text)
.quality(Quality::new(5)?)
.build()?;
Implementations§
Source§impl BrotliEncoderOptions
impl BrotliEncoderOptions
Sourcepub fn new() -> BrotliEncoderOptions
pub fn new() -> BrotliEncoderOptions
Creates a new blank set encoder options.
initially no modifications are applied to the encoder and everything is set to its default values.
Sourcepub fn mode(&mut self, mode: CompressionMode) -> &mut BrotliEncoderOptions
pub fn mode(&mut self, mode: CompressionMode) -> &mut BrotliEncoderOptions
Allows to tune a brotli compressor for a specific type of input.
Sourcepub fn quality(&mut self, quality: Quality) -> &mut BrotliEncoderOptions
pub fn quality(&mut self, quality: Quality) -> &mut BrotliEncoderOptions
The main compression speed-desnity lever. Higher quality means better
compression ratios at the expense of slower compression times. For more
information see Quality
Sourcepub fn window_size(
&mut self,
window_size: WindowSize,
) -> &mut BrotliEncoderOptions
pub fn window_size( &mut self, window_size: WindowSize, ) -> &mut BrotliEncoderOptions
Recommended sliding LZ77 window size according to RFC7932 (Brotli
proper). For more information see WindowSize
.
Sourcepub fn large_window_size(
&mut self,
large_window_size: LargeWindowSize,
) -> &mut BrotliEncoderOptions
pub fn large_window_size( &mut self, large_window_size: LargeWindowSize, ) -> &mut BrotliEncoderOptions
The non-standard large window size to use. For more information see
LargeWindowSize
.
Warning: The decompressor needs explicit support in order to use this
feature. This is not supported by the convenience decompress
function. A matching BrotliDecoder
must set large_window_size
to
true to decode non standard window sizes properly.
Sourcepub fn block_size(&mut self, block_size: BlockSize) -> &mut BrotliEncoderOptions
pub fn block_size(&mut self, block_size: BlockSize) -> &mut BrotliEncoderOptions
The recommended input block size to use.
The encoder may reduce this value, e.g. when the input is much smaller than the input block size.
Sourcepub fn disable_context_modeling(
&mut self,
disable_context_modeling: bool,
) -> &mut BrotliEncoderOptions
pub fn disable_context_modeling( &mut self, disable_context_modeling: bool, ) -> &mut BrotliEncoderOptions
Disable “literal context modeling” format feature.
Disabling literal context modeling decreases compression ratio in favor of decompression speed.
Sourcepub fn size_hint(&mut self, size_hint: u32) -> &mut BrotliEncoderOptions
pub fn size_hint(&mut self, size_hint: u32) -> &mut BrotliEncoderOptions
Estimated total input size.
This is 0 by default, which corresponds to the size being unknown.
Sourcepub fn postfix_bits(&mut self, postfix_bits: u32) -> &mut BrotliEncoderOptions
pub fn postfix_bits(&mut self, postfix_bits: u32) -> &mut BrotliEncoderOptions
The number of postfix bits to use
The encoder may change this value on the fly.
Valid ranges are from 0
to 3
(BROTLI_MAX_NPOSTFIX
) inclusive.
Sourcepub fn direct_distance_codes(
&mut self,
direct_distance_codes: u32,
) -> &mut BrotliEncoderOptions
pub fn direct_distance_codes( &mut self, direct_distance_codes: u32, ) -> &mut BrotliEncoderOptions
Recommended number of direct distance codes.
The encoder may change this value on the fly.
Valid range is from 0 to (15 << postfix) inclusive in steps of (1 << postfix), where postfix is the number of postfix bits.
Sourcepub fn stream_offset(&mut self, stream_offset: u32) -> &mut BrotliEncoderOptions
pub fn stream_offset(&mut self, stream_offset: u32) -> &mut BrotliEncoderOptions
Number of bytes already processed by a different instance.
It is worth noting that when using this parameter, all other encoders must share the same parameters, so that all encoded parts obey the same restrictions as implied by the header of the compression stream.
If the offset is non-zero, the stream header is omitted. Values greater than 2**30 are not allowed.
Sourcepub fn build(&self) -> Result<BrotliEncoder, SetParameterError>
pub fn build(&self) -> Result<BrotliEncoder, SetParameterError>
Creates a brotli encoder with the specified settings using allocator
alloc
.
§Errors
If any of the preconditions of the parameters are violated, an error is returned.
Trait Implementations§
Source§impl Clone for BrotliEncoderOptions
impl Clone for BrotliEncoderOptions
Source§fn clone(&self) -> BrotliEncoderOptions
fn clone(&self) -> BrotliEncoderOptions
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more