lz4_java_wrc/lib.rs
1#![warn(missing_docs)]
2
3//! A Rust implementation of the [LZ4BlockOutputStream] format from [lz4-java].
4//!
5//! **Beware**: this format is not compatible with the standard [LZ4 Block format].
6//! You should not use it if you unless you have to work with some historical data compressed using the Java code.
7//!
8//! [LZ4BlockOutputStream]: https://github.com/lz4/lz4-java/blob/1.8.0/src/java/net/jpountz/lz4/LZ4BlockOutputStream.java
9//! [lz4-java]: https://github.com/lz4/lz4-java
10//! [LZ4 Block format]: https://github.com/lz4/lz4/blob/dev/doc/lz4_Block_format.md
11//!
12//! # Example
13//!
14//! ```rust
15//! use lz4_java_wrc::{Lz4BlockInput, Lz4BlockOutput};
16//! use std::io::{Read, Result, Write};
17//!
18//! fn compress(d: &str) -> Result<Vec<u8>> {
19//! let mut compressed = Vec::new();
20//! Lz4BlockOutput::new(&mut compressed).write_all(d.as_bytes())?;
21//! Ok(compressed)
22//! }
23//! fn decompress(r: &[u8]) -> Result<String> {
24//! let mut decompressed = String::new();
25//! Lz4BlockInput::new(r).read_to_string(&mut decompressed)?;
26//! Ok(decompressed)
27//! }
28//!
29//! fn main() -> Result<()> {
30//! // compress the string
31//! let compressed = compress("Hello World!")?;
32//!
33//! // decompress back into the original value
34//! let decompressed = decompress(compressed.as_slice())?;
35//! println!("{}", decompressed);
36//! Ok(())
37//! }
38//! ```
39//!
40//! # Feature Flags
41//!
42//! - `use_lz4_flex`: use `lz4_flex` as lz4 compression library (enabled by default)
43//! - `use_lz4-sys`: use `lz4-sys` as lz4 compression library (disabled by default)
44//!
45//! When compiling with one of the lz4 compression library, it is used by default.
46//! When compiling with both of them, one can choose with the [`Context`] enum.
47
48mod common;
49mod compression;
50mod lz4_block_header;
51mod lz4_block_input;
52mod lz4_block_output;
53
54pub use compression::{Compression, Context};
55pub use lz4_block_input::{Lz4BlockInput, Lz4BlockInputBase};
56pub use lz4_block_output::{Lz4BlockOutput, Lz4BlockOutputBase};