Crate lzfse_rust[−][src]
This crate provides an enhanced implementation of the LZFSE compression library.
Install
Simply configure your Cargo.toml
:
[dependencies]
lzfse_rust = "0.1"
Overview.
This crate provides two LZFSE engines: one operating over user supplied memory buffers, and one operating over internal ring buffers.
The memory buffered engine works directly with input and output buffers that we supply.
It is exposed via LzfseEncoder and LzfseDecoder objects.
We would consider this engine when operating on &[u8]
and Vec<u8>
objects.
The ring buffered engine works by streaming data in and out of it’s ring buffers. It is exposed via LzfseRingEncoder and LzfseRingDecoder objects. We would consider this engine when operating on IO streams, or when we want to expose a Read or Write interface.
Example: compress IO data
This program compresses data from stdin
into stdout
. This example can be found in
examples/compress_ring.rs
use lzfse_rust::LzfseRingEncoder; use std::io; fn main() -> io::Result<()> { let mut rdr = io::stdin(); let mut wtr = io::stdout(); let mut encoder = LzfseRingEncoder::default(); encoder.encode(&mut rdr, &mut wtr)?; Ok(()) }
Example: decompress IO data
This program decompresses data from stdin
into stdout
. This example can be found in
examples/decompress_ring.rs
use lzfse_rust::LzfseRingDecoder; use std::io; fn main() -> io::Result<()> { let mut rdr = io::stdin(); let mut wtr = io::stdout(); let mut decoder = LzfseRingDecoder::default(); decoder.decode(&mut rdr, &mut wtr)?; Ok(()) }
Example: compress buffered data
This program compresses data from stdin
into stdout
. This example can be found in
examples/compress.rs
use std::io::{self, Read, Write}; fn main() -> io::Result<()> { // Read stdin into src. let mut rdr = io::stdin(); let mut src = Vec::default(); rdr.read_to_end(&mut src)?; // Compress src into dst. let mut dst = Vec::default(); lzfse_rust::encode_bytes(&src, &mut dst)?; // Write dst into stdout. let mut wtr = io::stdout(); wtr.write_all(&dst)?; Ok(()) }
Example: decompress buffered data
This program decompresses data from stdin
into stdout
. This example can be found in
examples/decompress.rs
use std::io::{self, Read, Write}; fn main() -> io::Result<()> { // Read stdin into src. let mut rdr = io::stdin(); let mut src = Vec::default(); rdr.read_to_end(&mut src)?; // Compress src into dst. let mut dst = Vec::default(); lzfse_rust::encode_bytes(&src, &mut dst)?; // Write dst into stdout. let mut wtr = io::stdout(); wtr.write_all(&dst)?; Ok(()) }
Structs
LzfseDecoder | LZFSE decoder. |
LzfseEncoder | LZFSE encoder. |
LzfseReader | LZFSE decoding reader. |
LzfseReaderBytes | LZFSE decoding byte reader. |
LzfseRingDecoder | LZFSE ring decoder. |
LzfseRingEncoder | LZFSE ring encoder. |
LzfseWriter | LZFSE encoding writer. |
LzfseWriterBytes | LZFSE encoding byte writer. |
Enums
Error | Decoding errors. |
FseErrorKind | FSE error kinds. |
VnErrorKind | VN error kinds. |
Functions
decode_bytes | Decode |
encode_bytes | Encode |
Type Definitions
Result | Decoding error Result. |