Expand description
The crate is started as a port of the C++ lzokay library.
LZO compresses a block of data into matches (a sliding dictionary) and runs of non-matching literals to produce good results on highly redundant data
— Wikipedia
There is no publicly available documentation of the LZO format. A good introduction is available in the Linux Kernel documentation
The crate is no_std. Decompression works without any allocation.
For compression, a Dict instance is needed.
§Examples
use lzallright::{compress, decompress, worst_case_len, Dict};
let input = b"hello world";
// You should reuse the dictionary across calls.
let mut dict = Dict::new();
let mut compressed = vec![0u8; worst_case_len(input.len())];
let n = compress(input, &mut compressed, &mut dict).unwrap();
compressed.truncate(n);
let mut output = vec![0u8; input.len()];
let m = decompress(&compressed, &mut output).unwrap();
assert_eq!(&output[..m], input);Structs§
- Dict
- Compressor state. Contains a sliding window and two extremely simple hash-tables.
- Error
- The error type of compression and decompression operations.
Enums§
- Error
Kind - List specifying categories of compression and decompression related errors.
Functions§
- compress
- Compresses the content of the slice
srcintoout, usingdictto store compressor state. In case of success, returns the number of bytes produced. - decompress
- Decompresses the LZO stream
srcintodstand returns the number of bytes written. - worst_
case_ len - Returns the maximum length needed to hold the compressed data of
size.