#[non_exhaustive]#[repr(u8)]pub enum CompressionType {
None = 0,
Gzip = 1,
Snappy = 2,
Lz4 = 3,
Zstd = 4,
}Expand description
Codec identifier matching the lowest three bits of Kafka’s record-batch attribute byte.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Implementations§
Source§impl CompressionType
impl CompressionType
Sourcepub fn from_attribute_bits(b: u8) -> Option<Self>
pub fn from_attribute_bits(b: u8) -> Option<Self>
Decode the lowest three bits of a Kafka record-batch attribute byte.
The method returns None for codec ids outside 0..=4.
Sourcepub fn as_attribute_bits(self) -> u8
pub fn as_attribute_bits(self) -> u8
Encode this codec into the lowest three bits of an attribute byte.
Sourcepub const fn default_level(self) -> Option<i32>
pub const fn default_level(self) -> Option<i32>
Kafka’s default compression level of the codec
(CompressionType.defaultLevel), or None when the codec has no
levels.
Sourcepub const fn min_level(self) -> Option<i32>
pub const fn min_level(self) -> Option<i32>
Kafka’s lowest compression level of the codec
(CompressionType.minLevel), or None when the codec has no levels.
Sourcepub const fn max_level(self) -> Option<i32>
pub const fn max_level(self) -> Option<i32>
Kafka’s highest compression level of the codec
(CompressionType.maxLevel), or None when the codec has no levels.
Sourcepub fn check_level(self, level: i32) -> Result<(), CompressionError>
pub fn check_level(self, level: i32) -> Result<(), CompressionError>
Check level as Kafka’s CompressionType.levelValidator does (KIP-390).
Gzip accepts 1 to 9, and also -1, which is the zlib default. Lz4 and zstd accept their range only.
§Errors
Returns CompressionError::InvalidLevel with Kafka’s message when the
level is outside the range, or when the codec has no levels.
Trait Implementations§
Source§impl Clone for CompressionType
impl Clone for CompressionType
Source§fn clone(&self) -> CompressionType
fn clone(&self) -> CompressionType
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for CompressionType
Source§impl Debug for CompressionType
impl Debug for CompressionType
impl Eq for CompressionType
Source§impl Hash for CompressionType
impl Hash for CompressionType
Source§impl PartialEq for CompressionType
impl PartialEq for CompressionType
Source§fn eq(&self, other: &CompressionType) -> bool
fn eq(&self, other: &CompressionType) -> bool
self and other values to be equal, and is used by ==.