#stream #bindings #encoding #reader-writer #api-bindings #exposed #lzlib

lzip

Bindings to lzlib for lzip compression and decompression exposed as Reader/Writer streams

2 releases

Uses old Rust 2015

0.1.1 Apr 29, 2022
0.1.0 Apr 2, 2022

#9 in #exposed

24 downloads per month

MIT/Apache

190KB
4.5K SLoC

C 3.5K SLoC // 0.1% comments Shell 399 SLoC // 0.0% comments Rust 272 SLoC

lzip

Documentation

A streaming compression/decompression library for rust with bindings to lzlib.

# Cargo.toml
[dependencies]
lzip = "0.1"

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.


lib.rs:

Lzip compression for Rust

This library contains bindings to lzlib to support lzip compression and decompression for Rust. The streams offered in this library are primarily found in the reader and writer modules. Both compressors and decompressors are available in each module depending on what operation you need.

Example

use std::io::prelude::*;
use lzip::read::{LzEncoder, LzDecoder};

// Round trip some bytes from a byte source, into a compressor, into a
// decompressor, and finally into a vector.
let data = "Hello, World!".as_bytes();
let compressor = LzEncoder::new(data, 9);
let mut decompressor = LzDecoder::new(compressor);

let mut contents = String::new();
decompressor.read_to_string(&mut contents).unwrap();
assert_eq!(contents, "Hello, World!");

Async I/O

This crate optionally can support async I/O streams with the Tokio stack via the tokio feature of this crate:

lzip = { version = "0.1", features = ["tokio"] }

All methods are internally capable of working with streams that may return ErrorKind::WouldBlock when they're not ready to perform the particular operation.

Note that care needs to be taken when using these objects, however. The Tokio runtime, in particular, requires that data is fully flushed before dropping streams. For compatibility with blocking streams all streams are flushed/written when they are dropped, and this is not always a suitable time to perform I/O. If I/O streams are flushed before drop, however, then these operations will be a noop.

Dependencies

~0.4–425KB