Struct yazi::Encoder

source ·
pub struct Encoder(/* private fields */);
Expand description

Stateful context for compression.

See the crate level compression section for detailed usage.

Implementations§

source§

impl Encoder

source

pub fn new() -> Self

Creates a new deflate encoder. Note that creating an encoder with this method allocates a large (200-300k) chunk of data on the stack and is likely to cause an overflow if not carefully managed. See the boxed() constructor for a safer method that allocates on the heap.

source

pub fn boxed() -> Box<Self>

Creates a new deflate encoder on the heap.

source

pub fn set_format(&mut self, format: Format)

Sets the format of the output bitstream for the next usage of the encoder.

source

pub fn set_level(&mut self, level: CompressionLevel)

Sets the compression level for the next usage of the encoder.

source

pub fn set_strategy(&mut self, strategy: CompressionStrategy)

Sets the compression strategy for the next usage of the encoder.

source

pub fn stream<'a, W: Write>( &'a mut self, writer: &'a mut W ) -> EncoderStream<'a, impl Sink + 'a>

Creates an encoder stream that will write into the specified writer.

source

pub fn stream_into_vec<'a>( &'a mut self, vec: &'a mut Vec<u8> ) -> EncoderStream<'a, impl Sink + 'a>

Creates an encoder stream that will write into the specified vector. The resulting stream will not clear the vector but will instead append the compressed data.

source

pub fn stream_into_buf<'a>( &'a mut self, buf: &'a mut [u8] ) -> EncoderStream<'a, impl Sink + 'a>

Creates an encoder stream that will write into the specified buffer. The stream will generate an overflow error if the buffer is not large enough to contain the compressed data.

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. 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 Twhere 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, U> TryFrom<U> for Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.