Module block

Source
Expand description

LZ4 Block Format

As defined in https://github.com/lz4/lz4/blob/dev/doc/lz4_Block_format.md

Currently for no_std support only the block format is supported.

§Example: block format roundtrip

use lz4_flex::block::{compress_prepend_size, decompress_size_prepended};
let input: &[u8] = b"Hello people, what's up?";
let compressed = compress_prepend_size(input);
let uncompressed = decompress_size_prepended(&compressed).unwrap();
assert_eq!(input, uncompressed);

Enums§

CompressError
Errors that can happen during compression.
DecompressError
An error representing invalid compressed data.

Functions§

compress
Compress all bytes of input.
compress_into
Compress all bytes of input into output. The method chooses an appropriate hashtable to lookup duplicates. output should be preallocated with a size of get_maximum_output_size.
compress_into_with_dict
Compress all bytes of input into output. The method chooses an appropriate hashtable to lookup duplicates. output should be preallocated with a size of get_maximum_output_size.
compress_prepend_size
Compress all bytes of input into output. The uncompressed size will be prepended as a little endian u32. Can be used in conjunction with decompress_size_prepended
compress_prepend_size_with_dict
Compress all bytes of input into output. The uncompressed size will be prepended as a little endian u32. Can be used in conjunction with decompress_size_prepended_with_dict
compress_with_dict
Compress all bytes of input with an external dictionary.
decompress
Decompress all bytes of input into a new vec. The passed parameter min_uncompressed_size needs to be equal or larger than the uncompressed size.
decompress_into
Decompress all bytes of input into output. output should be preallocated with a size of of the uncompressed data.
decompress_into_with_dict
Decompress all bytes of input into output.
decompress_size_prepended
Decompress all bytes of input into a new vec. The first 4 bytes are the uncompressed size in little endian. Can be used in conjunction with compress_prepend_size
decompress_size_prepended_with_dict
Decompress all bytes of input into a new vec. The first 4 bytes are the uncompressed size in little endian. Can be used in conjunction with compress_prepend_size_with_dict
decompress_with_dict
Decompress all bytes of input into a new vec. The passed parameter min_uncompressed_size needs to be equal or larger than the uncompressed size.
get_maximum_output_size
Returns the maximum output size of the compressed data. Can be used to preallocate capacity on the output vector
uncompressed_size
This can be used in conjunction with decompress_size_prepended. It will read the first 4 bytes as little-endian encoded length, and return the rest of the bytes after the length encoding.