#[non_exhaustive]pub enum CompressionType {
None,
Lz4,
Zstd(i32),
ZstdDict {
level: i32,
dict_id: u32,
},
}Expand description
Compression algorithm to use
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
None
No compression
Not recommended.
Lz4
LZ4 compression
Recommended for use cases with a focus on speed over compression ratio.
Zstd(i32)
Zstd compression
Provides significantly better compression ratios than LZ4 with reasonable decompression speed (~1.5 GB/s).
Compression level can be adjusted (1-22, default 3):
- 1 optimizes for speed
- 3 is a good default (recommended)
- 9+ optimizes for compression ratio
Recommended for cold/archival data where compression ratio matters more than raw speed.
ZstdDict
Zstd compression with a pre-trained dictionary
Uses a pre-trained dictionary for significantly better compression ratios on small blocks (4–64 KiB), especially when data has recurring patterns.
level is the compression level (1–22), dict_id identifies the
dictionary (truncated xxh3 hash of the dictionary bytes). The actual
dictionary must be provided via Config or the relevant writer/reader.
Implementations§
Source§impl CompressionType
impl CompressionType
Sourcepub fn dict_id(&self) -> u32
pub fn dict_id(&self) -> u32
Returns the zstd dictionary id encoded in this compression
configuration, or 0 when no dictionary applies. Used to
populate crate::table::block::BlockIdentity::dict_id
from a CompressionType at the call site without each
caller re-doing the ZstdDict { dict_id, .. } destructure.
Sourcepub fn zstd(level: i32) -> Result<Self>
pub fn zstd(level: i32) -> Result<Self>
Create a zstd compression configuration with a checked level.
This is the recommended way to construct a CompressionType::Zstd
value, as it validates the level before any I/O occurs.
§Errors
Returns an error if level is outside the valid range -128..=22 (zstd
negative “fast” levels and 0 = default are accepted; the on-disk format
stores the level in one signed byte).
Sourcepub fn zstd_dict(level: i32, dict_id: u32) -> Result<Self>
pub fn zstd_dict(level: i32, dict_id: u32) -> Result<Self>
Create a zstd dictionary compression configuration with checked level.
The dict_id should come from ZstdDictionary::id to ensure
consistency between the compression type stored on disk and the
dictionary used at runtime.
§Errors
Returns an error if level is outside the valid range -128..=22 (zstd
negative “fast” levels and 0 = default are accepted; the on-disk format
stores the level in one signed byte).
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
Source§impl Display for CompressionType
impl Display for CompressionType
impl Eq 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 ==.impl StructuralPartialEq for CompressionType
Auto Trait Implementations§
impl Freeze for CompressionType
impl RefUnwindSafe for CompressionType
impl Send for CompressionType
impl Sync for CompressionType
impl Unpin for CompressionType
impl UnsafeUnpin for CompressionType
impl UnwindSafe for CompressionType
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more