#[non_exhaustive]#[repr(i16)]pub enum Compression {
None = 0,
Gzip = 1,
Snappy = 2,
Lz4 = 3,
Zstd = 4,
}Expand description
Kafka record-batch compression codec, encoded in bits 0–2 of the batch
attributes field.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
None = 0
No compression.
Gzip = 1
Gzip (flate2).
Snappy = 2
Snappy (snap).
Lz4 = 3
LZ4 frame format (lz4_flex).
Zstd = 4
Zstandard (zstd crate).
Implementations§
Source§impl Compression
impl Compression
Sourcepub const fn from_attributes(attributes: i16) -> Result<Self>
pub const fn from_attributes(attributes: i16) -> Result<Self>
Decode the codec from a record-batch attributes field.
Only bits 0–2 are examined; higher bits are masked off.
Sourcepub fn compress(self, payload: &[u8]) -> Result<Vec<u8>>
pub fn compress(self, payload: &[u8]) -> Result<Vec<u8>>
Compress payload at the codec default level.
Sourcepub fn compress_with_level(
self,
payload: &[u8],
level: Option<i32>,
) -> Result<Vec<u8>>
pub fn compress_with_level( self, payload: &[u8], level: Option<i32>, ) -> Result<Vec<u8>>
Compress payload at the given level (codec-specific).
Gzipaccepts0..=9, default6.Zstdaccepts1..=22, default3.Snappyignores the level.Lz4level handling depends on the active backend feature:- with
lz4only — level ignored, always fast mode. - with
lz4-hc— level0..=2→ fast,3..=12→ HC mode, values above12clamp to12, negative/zero levels clamp to fast level1.
- with
Trait Implementations§
Source§impl Clone for Compression
impl Clone for Compression
Source§fn clone(&self) -> Compression
fn clone(&self) -> Compression
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl Copy for Compression
Source§impl Debug for Compression
impl Debug for Compression
impl Eq for Compression
Source§impl PartialEq for Compression
impl PartialEq for Compression
Source§fn eq(&self, other: &Compression) -> bool
fn eq(&self, other: &Compression) -> bool
Tests for
self and other values to be equal, and is used by ==.impl StructuralPartialEq for Compression
Auto Trait Implementations§
impl Freeze for Compression
impl RefUnwindSafe for Compression
impl Send for Compression
impl Sync for Compression
impl Unpin for Compression
impl UnsafeUnpin for Compression
impl UnwindSafe for Compression
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more