Struct BrotliEncoderOptions

Source
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

Source

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.

Source

pub fn mode(&mut self, mode: CompressionMode) -> &mut BrotliEncoderOptions

Allows to tune a brotli compressor for a specific type of input.

Source

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

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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

Source§

fn clone(&self) -> BrotliEncoderOptions

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for BrotliEncoderOptions

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Default for BrotliEncoderOptions

Source§

fn default() -> BrotliEncoderOptions

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.