Expand description
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
- Represents the compression mode do be used.
Functions
- 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.
- Returns the size of the buffer that is guaranteed to hold the result of compressing
uncompressed_size
bytes of in data. Returns std::io::Error with ErrorKind::InvalidInput if input data is too long to be compressed by lz4. - Compresses the full
src
buffer using the specified CompressionMode, where None and Some(Default) are treated equally, writing compressed bytes tobuffer
. - Decompresses the src buffer. If uncompressed_size is None, the source length will be read from the start of the input buffer.