lz4_decompress

Crates.iolz4_decompress
lib.rslz4_decompress
version0.13.0
created_at2025-12-20 12:29:12.85782+00
updated_at2025-12-20 12:29:12.85782+00
descriptionPure Rust implementation of lz4 decompression.
homepagehttps://github.com/traceflight/lz4_decompress
repositoryhttps://github.com/traceflight/lz4_decompress
max_upload_size
id1996453
size91,277
Julian Wang (traceflight)

documentation

README

Docs Crates.io

lz4_decompress

Pure Rust implementation of lz4 decompression.

Fork of the awesome 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.

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);
}
Commit count: 0

cargo fmt