pub struct Encoder(/* private fields */);Expand description
An encoder for compressing data.
Implementations§
Source§impl Encoder
impl Encoder
Sourcepub fn new(params: CParams) -> Result<Self, Error>
pub fn new(params: CParams) -> Result<Self, Error>
Create a new Encoder with the given compression parameters.
Sourcepub fn compress(&mut self, src: &[u8]) -> Result<Chunk<'static>, Error>
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.
Sourcepub fn compress_into(
&mut self,
src: &[u8],
dst: &mut [MaybeUninit<u8>],
) -> Result<usize, Error>
pub fn compress_into( &mut self, src: &[u8], dst: &mut [MaybeUninit<u8>], ) -> Result<usize, Error>
Compress the given bytes into a pre-allocated buffer.
Sourcepub fn compress_repeatval(
&self,
count: usize,
value: &RepeatedValue<'_>,
) -> Result<Chunk<'static>, Error>
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.
Sourcepub fn compress_repeatval_into(
&self,
count: usize,
value: &RepeatedValue<'_>,
dst: &mut [MaybeUninit<u8>],
) -> Result<usize, Error>
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.