Struct Encoder

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

An encoder for compressing data.

Implementations§

Source§

impl Encoder

Source

pub fn new(params: CParams) -> Result<Self, Error>

Create a new Encoder with the given compression parameters.

Source

pub fn compress(&mut self, src: &[u8]) -> Result<Chunk<'static>, Error>

Compress the given bytes into a new allocated Chunk.

Note that this function allocates a new Vec<u8> for the compressed data with the maximum possible size required for it (uncompressed size + 32), which may be larger than whats actually needed. If this function is used in a critical performance path, consider using compress_into instead, allowing you to provide a pre-allocated buffer which can be used repeatedly without the overhead of allocations.

Source

pub fn compress_into( &mut self, src: &[u8], dst: &mut [MaybeUninit<u8>], ) -> Result<usize, Error>

Compress the given bytes into a pre-allocated buffer.

Source

pub fn compress_repeatval( &self, count: usize, value: &RepeatedValue<'_>, ) -> Result<Chunk<'static>, Error>

Compress a repeated value into a new allocated Chunk.

blosc2 can create chunks of repeated values in a very efficient way without actually storing the repeated values many times.

§Arguments
  • count - The number of times the value should be repeated.
  • value - The value to repeat.
§Returns

A Chunk containing the compressed repeated value.

Source

pub fn compress_repeatval_into( &self, count: usize, value: &RepeatedValue<'_>, dst: &mut [MaybeUninit<u8>], ) -> Result<usize, Error>

Compress a repeated value into a pre-allocated buffer.

This function is similar to Encoder::compress_repeatval, but allows you to provide a pre-allocated buffer to store the compressed data.

Source

pub fn params(&self) -> CParams

Get the compression parameters used by this encoder.

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> 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, 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.