#[non_exhaustive]pub enum Format {
Raw,
Zlib,
Gzip,
}Expand description
A compressed format.
§Examples
use compress_lib::{Format, gzip, zlib};
assert_eq!(Format::detect(&gzip::compress(b"x")), Some(Format::Gzip));
assert_eq!(Format::detect(&zlib::compress(b"x")), Some(Format::Zlib));
assert_eq!(Format::detect(b"plain text"), None);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.
Raw
Raw DEFLATE (RFC 1951): no header, no checksum.
Zlib
zlib (RFC 1950); also HTTP’s deflate content coding.
Gzip
gzip (RFC 1952); HTTP’s gzip content coding.
Implementations§
Source§impl Format
impl Format
Sourcepub fn detect(data: &[u8]) -> Option<Format>
pub fn detect(data: &[u8]) -> Option<Format>
Recognises gzip by its magic number and zlib by its header check. Raw DEFLATE has no header and is never guessed. Needs at least two bytes.
§Examples
use compress_lib::Format;
assert_eq!(Format::detect(&[0x1F, 0x8B]), Some(Format::Gzip));
assert_eq!(Format::detect(&[0x78, 0x9C]), Some(Format::Zlib));
assert_eq!(Format::detect(&[0x78]), None);Trait Implementations§
impl Copy for Format
impl Eq for Format
impl StructuralPartialEq for Format
Auto Trait Implementations§
impl Forget for Format
impl Freeze for Format
impl RefUnwindSafe for Format
impl Send for Format
impl Sync for Format
impl Unpin for Format
impl UnsafeUnpin for Format
impl UnwindSafe for Format
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