| 1 |
//! `bzip2_rs` is a pure Rust bzip2 decoder. |
| 2 |
//! |
| 3 |
//! ## Main APIs |
| 4 |
//! |
| 5 |
//! * [`Decoder`]: low-level, no IO, bzip2 decoder |
| 6 |
//! * [`DecoderReader`]: high-level synchronous bzip2 decoder |
| 7 |
//! |
| 8 |
//! ## Features |
| 9 |
//! |
| 10 |
//! * Default features: Rust >= 1.34.2 is supported |
| 11 |
//! * `rustc_1_37`: bump MSRV to 1.37, enable more optimizations |
| 12 |
//! * `nightly`: require Rust Nightly, enable more optimizations |
| 13 |
//! |
| 14 |
//! ## Usage |
| 15 |
//! |
| 16 |
//! ```rust,no_run |
| 17 |
//! use std::fs::File; |
| 18 |
//! use std::io; |
| 19 |
//! use bzip2_rs::DecoderReader; |
| 20 |
//! |
| 21 |
//! # fn main() -> Result<(), Box<dyn std::error::Error>> { |
| 22 |
//! let mut compressed_file = File::open("input.bz2")?; |
| 23 |
//! let mut decompressed_output = File::create("output")?; |
| 24 |
//! |
| 25 |
//! let mut reader = DecoderReader::new(compressed_file); |
| 26 |
//! io::copy(&mut reader, &mut decompressed_output)?; |
| 27 |
//! # Ok(()) |
| 28 |
//! # } |
| 29 |
//! ``` |
| 30 |
//! |
| 31 |
//! [`Decoder`]: crate::decoder::Decoder |
| 32 |
|
| 33 |
#![deny( |
| 34 |
trivial_casts, |
| 35 |
trivial_numeric_casts, |
| 36 |
rust_2018_idioms, |
| 37 |
clippy::cast_lossless, |
| 38 |
clippy::doc_markdown, |
| 39 |
missing_docs, |
| 40 |
broken_intra_doc_links |
| 41 |
)] |
| 42 |
#![forbid(unsafe_code)] |
| 43 |
// TODO: remove once rustc 1.35 is our MSRV |
| 44 |
#![allow(clippy::manual_range_contains)] |
| 45 |
|
| 46 |
#[doc(no_inline)] |
| 47 |
pub use self::decoder::DecoderReader; |
| 48 |
|
| 49 |
mod bitreader; |
| 50 |
pub mod block; |
| 51 |
mod crc; |
| 52 |
pub mod decoder; |
| 53 |
pub mod header; |
| 54 |
mod huffman; |
| 55 |
mod move_to_front; |
| 56 |
|
| 57 |
#[cfg(feature = "nightly")] |
| 58 |
const LEN_258: usize = 258; |
| 59 |
#[cfg(not(feature = "nightly"))] |
| 60 |
const LEN_258: usize = 512; |