7 unstable releases (3 breaking)

new 0.5.2+496255c Oct 5, 2024
0.5.1+496255c Oct 5, 2024
0.4.0+496255c Sep 26, 2024
0.3.1+496255c Sep 24, 2024
0.2.0+496255c Sep 22, 2024

#132 in Compression

Download history 2155/week @ 2024-09-18 364/week @ 2024-09-25 1863/week @ 2024-10-02

4,382 downloads per month
Used in libcramjam

MIT AND BSD-3-Clause

4.5MB
79K SLoC

Assembly 33K SLoC // 0.2% comments C 29K SLoC // 0.1% comments GNU Style Assembly 11K SLoC // 0.2% comments Rust 3.5K SLoC // 0.0% comments Shell 1K SLoC // 0.1% comments Automake 574 SLoC // 0.4% comments Bitbake 340 SLoC // 0.2% comments

isal-rs

CI Latest version Documentation License

Rust bindings for isa-l


Supports the following codecs using the ISA-L library under the hood:

  • GZIP
    • isal::igzip::read::GzipEncoder/GzipDecoder
    • isal::igzip::write::GzipEncoder/GzipDecoder
  • DEFLATE
    • isal::igzip::read::DeflateEncoder/DeflateDecoder
    • isal::igzip::write::DeflateEncoder/DeflateDecoder
  • ZLIB
    • isal::igzip::read::ZlibEncoder/ZlibDecoder
    • isal::igzip::write::ZlibEncoder/ZlibDecoder
    • TODO:
      • Support an 'unsafe' setting where one can ignore step of verifying Adler32 checksum.

Or can use functions of de/compress and de/compress_into


Building requires some system tools like autotools, nasm, make, and anything the official ISA-L repo suggests. On Windows the build is invoked with nmake, other systems use the ./autogen.sh and ./configure setups.


Examples:

Functions like compress_into and decompress

(Similar functionality with compress and decompress_into)

use isal::igzip::{CompressionLevel, Codec, compress_into, decompress};

let mut compressed = vec![0u8; 100];
let nbytes = compress_into(b"foobar", &mut compressed, CompressionLevel::Three, Codec::Gzip).unwrap();

let decompressed = decompress(&compressed[..nbytes], Codec::Gzip).unwrap();
assert_eq!(decompressed.as_slice(), b"foobar");

Compress using the Encoder/Decoder structs implementing io::Read

use std::{io, io::Read};
use isal::igzip::{read::{Encoder, GzipEncoder}, CompressionLevel, decompress, Codec};

let data = b"Hello, World!".to_vec();

// Note these two encoders are equivelent...
let mut encoder = GzipEncoder::new(data.as_slice(), CompressionLevel::Three);
let mut encoder = Encoder::new(data.as_slice(), CompressionLevel::Three, Codec::Gzip);

// Number of compressed bytes written to `output`
let mut compressed = vec![];
let n = io::copy(&mut encoder, &mut compressed).unwrap();
assert_eq!(n as usize, compressed.len());

let decompressed = decompress(compressed.as_slice(), Codec::Gzip).unwrap();
assert_eq!(decompressed.as_slice(), data);

Decompress using the Encoder/Decoder structs implementing io::Write

use std::{io, io::Write};
use isal::igzip::{write::Decoder, CompressionLevel, compress, Codec};

let data = b"Hello, World!".to_vec();
let compressed = compress(io::Cursor::new(data.as_slice()), CompressionLevel::Three, Codec::Gzip).unwrap();

let mut decompressed = vec![];
let mut decoder = Decoder::new(&mut decompressed, Codec::Gzip);

// Number of compressed bytes written to `output`
let n = io::copy(&mut io::Cursor::new(&compressed), &mut decoder).unwrap();
assert_eq!(n as usize, compressed.len());

assert_eq!(decompressed.as_slice(), data);

Benchmarks

Checkout the README in the benches directory.

Criterion benchmark report available here: https://milesgranger.github.io/isal-rs/benches/criterion/report/


Versioning:

Versions are specified in normal SemVer format, and a trailing "+<< commit hash >>" to indicate which commit in isa-l the crate is built against. ie: 0.1.0+62519d9

Dependencies