#[non_exhaustive]pub enum Compression {
None,
Gzip,
Bgzf,
Zstd,
}Expand description
Compression applied to a sequence file.
Marked #[non_exhaustive]: match with a _ arm. New containers keep
appearing — this list has already grown twice — and each one should be a
minor release rather than a breaking one.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
None
Plain, uncompressed bytes.
Gzip
One deflate stream, as gzip produces. Readable start to finish only.
Bgzf
Block-compressed gzip, as bgzip produces.
Valid gzip that any tool can decompress, but split into independent
members so that a reader with a .gzi index can seek into it. Costs a
percent or two of compression ratio and is what the samtools ecosystem
expects, so it is the default for compressed output.
Zstd
Zstandard (requires the zstd feature).
Compresses faster and smaller than gzip, which makes it attractive for
intermediate files, but the wider bioinformatics toolchain does not read
it and a plain zstd frame cannot be randomly accessed — so a reference
genome still wants Compression::Bgzf.
Implementations§
Source§impl Compression
impl Compression
Sourcepub const GZIP_MAGIC: [u8; 2]
pub const GZIP_MAGIC: [u8; 2]
The first two bytes of a gzip member.
Sourcepub const ZSTD_MAGIC: [u8; 4]
pub const ZSTD_MAGIC: [u8; 4]
The four-byte magic number of a Zstandard frame.
Sourcepub fn from_path<P: AsRef<Path>>(path: P) -> Compression
pub fn from_path<P: AsRef<Path>>(path: P) -> Compression
Infer compression from a file extension.
Note that .gz maps to Compression::Gzip rather than
Compression::Bgzf: an extension cannot tell the two apart, and only
the bytes can. Writers pick BGZF for .gz deliberately; readers sniff.
Sourcepub fn from_magic(bytes: &[u8]) -> Compression
pub fn from_magic(bytes: &[u8]) -> Compression
Infer compression from the leading bytes of a stream.
Does not distinguish plain gzip from BGZF — both report
Compression::Gzip, since telling them apart means parsing the extra
field. Use crate::bgzf::is_bgzf for that.
Trait Implementations§
Source§impl Clone for Compression
impl Clone for Compression
Source§fn clone(&self) -> Compression
fn clone(&self) -> Compression
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 Compression
Source§impl Debug for Compression
impl Debug for Compression
Source§impl Default for Compression
impl Default for Compression
Source§fn default() -> Compression
fn default() -> Compression
impl Eq for Compression
Source§impl Hash for Compression
impl Hash for Compression
Source§impl PartialEq for Compression
impl PartialEq for Compression
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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