#[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.