An open API service indexing awesome lists of open source software.

https://github.com/traceflight/lz4_decompress

Fastest pure Rust implementation of LZ4 decompression.
https://github.com/traceflight/lz4_decompress

Last synced: 5 months ago
JSON representation

Fastest pure Rust implementation of LZ4 decompression.

Awesome Lists containing this project

README

          

[![Docs](https://img.shields.io/docsrs/lz4_decompress)](https://docs.rs/lz4_decompress)
[![Crates.io](https://img.shields.io/crates/v/lz4_decompress.svg)](https://crates.io/crates/lz4_decompress)

# lz4_decompress
Pure Rust implementation of lz4 decompression.

Fork of the awesome [lz4_flex](https://github.com/PSeitz/lz4_flex), modified to support decompressing data without providing the minimal uncompressed size.

## Features
- LZ4 Block format
- LZ4 Frame format
- Decompress without providing the minimal uncompressed size

### Block Format
The block format is only valid for smaller data chunks as block is decompressed in memory.
For larger data use the frame format, which consists of multiple blocks.

```rust
use lz4_decompress::block::{decompress_safe, decompress};
use lz4_flex::block::compress_prepend_size;

fn main(){
let input: &[u8] = b"Hello people, what's up?";
// we use lz4_flex to compress
let compressed = compress_prepend_size(input);
let uncompressed = decompress_size_prepended(&compressed).unwrap();
assert_eq!(input, uncompressed);
// remove size prefix
let compressed_without_size = &compressed[4..];
// decompress without providing min uncompressed size
let uncompressed = decompress_safe(&compressed_without_size, None).unwrap();
assert_eq!(input, uncompressed);

let uncompressed = decompress(&compressed_without_size, 24).unwrap();
assert_eq!(input, uncompressed);
}
```