[−][src]Crate niffler
niffler
Simple and transparent support for compressed files.
This library provides two main features:
- sniffs out compression formats from input files and return a Read trait object ready for consumption.
- Create a Writer initialized with compression ready for writing.
The goal is to lower the barrier to open and use a file, especially in bioinformatics workflows.
Example
use niffler::{Error, compression}; let mut buffer = Vec::new(); { let mut writer = niffler::get_writer(Box::new(&mut buffer), compression::Format::Gzip, compression::Level::Nine)?; writer.write_all(b"hello")?; } let (mut reader, compression) = niffler::get_reader(Box::new(&buffer[..]))?; let mut contents = String::new(); reader.read_to_string(&mut contents)?; assert_eq!(compression, niffler::compression::Format::Gzip); assert_eq!(contents, "hello");
Re-exports
pub use crate::error::Error; |
Modules
compression | |
error |
Functions
from_path | Open a possibly compressed file and decompress it transparently. |
get_reader | Create a readable stream that can be read transparently even if the original stream is compress. Also returns the compression type of the original stream. |
get_writer | Create a new writable stream with the given compression format and level. |
to_path | Create a file with specific compression format. |