Skip to main content

Crate lzo

Crate lzo 

Source
Expand description

Safe, dependency-free, pure-Rust LZO1X decompressor.

Decodes raw LZO1X blocks as produced by lzo1x_1, lzo1x_1_15, and lzo1x_999 (the liblzo2 / lzop family) — a single compressed block with no container header or stored output size. The output length must be known (or upper-bounded) by the caller, exactly like the C lzo1x_decompress_safe.

Built decoder-first for untrusted input: #![forbid(unsafe_code)], zero dependencies, and fuzz-hardened, so a malformed or crafted block returns a typed Error rather than reading out of bounds or panicking.

// "hello, lzo world!" compressed by liblzo2's lzo1x_1.
let block = [34, 104,101,108,108,111,44,32,108,122,111,32,119,111,114,108,100,33, 17,0,0];
let mut out = [0u8; 17];
let n = lzo::decompress_into(&block, &mut out).unwrap();
assert_eq!(&out[..n], b"hello, lzo world!");

Enums§

Error
An error returned while decompressing an LZO1X block.

Functions§

decompress
Decompress a raw LZO1X block, allocating an output of at most max_len bytes. Returns the decompressed data.
decompress_into
Decompress a raw LZO1X block into dst, returning the number of bytes written. dst must be large enough to hold the entire decompressed output.