[][src]Module lz4::block

This module provides access to the block mode functions of the lz4 C library. It somehow resembles the Python-lz4 api, but using Rust's Option type, the function parameters have been a little simplified. As does python-lz4, this module supports prepending the compressed buffer with a u32 value representing the size of the original, uncompressed data.

Examples


use lz4::block::{compress,decompress};

let v = vec![0u8; 1024];

let comp_with_prefix = compress(&v, None, true).unwrap();
let comp_wo_prefix = compress(&v, None, false).unwrap();

assert_eq!(v, decompress(&comp_with_prefix, None).unwrap());
assert_eq!(v, decompress(&comp_wo_prefix, Some(1024)).unwrap());

Enums

CompressionMode

Represents the compression mode do be used.

Functions

compress

Compresses the full src buffer using the specified CompressionMode, where None and Some(Default) are treated equally. If prepend_size is set, the source length will be prepended to the output buffer.

decompress

Decompresses the src buffer. If uncompressed_size is None, the source length will be read from the start of the input buffer.