[−][src]Function lzzzz::lz4::compress
pub fn compress(src: &[u8], dst: &mut [u8], acc: i32) -> Result<usize>
Performs LZ4 block compression.
Ensure that the destination slice have enough capacity.
If dst.len()
is smaller than lz4::max_compressed_size(src.len())
,
this function may fail.
Returns the number of bytes written into the destination buffer.
Example
use lzzzz::lz4; let data = b"The quick brown fox jumps over the lazy dog."; let mut buf = [0u8; 256]; // The slice should have enough capacity. assert!(buf.len() >= lz4::max_compressed_size(data.len())); let len = lz4::compress(data, &mut buf, lz4::ACC_LEVEL_DEFAULT)?; let compressed = &buf[..len];