Expand description
This crate provides an enhanced implementation of the LZFSE compression library.
§Install
Simply configure your Cargo.toml
:
[dependencies]
lzfse_rust = "0.2"
§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 internal 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§
- Lzfse
Decoder - LZFSE decoder.
- Lzfse
Encoder - LZFSE encoder.
- Lzfse
Reader - LZFSE decoding reader.
- Lzfse
Reader Bytes - LZFSE decoding byte reader.
- Lzfse
Ring Decoder - LZFSE ring decoder.
- Lzfse
Ring Encoder - LZFSE ring encoder.
- Lzfse
Writer - LZFSE encoding writer.
- Lzfse
Writer Bytes - LZFSE encoding byte writer.
Enums§
- Error
- Decoding errors.
- FseError
Kind - FSE error kinds.
- VnError
Kind - VN error kinds.
Functions§
- decode_
bytes - Decode
src
intodst
returning the number of bytes written intodst
. - encode_
bytes - Encode
src
intodst
returning the number of bytes written intodst
.
Type Aliases§
- Result
- Decoding error Result.