1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
#![doc(html_root_url = "https://docs.rs/lzfse_rust/0.2.0")]
#![warn(missing_docs)]
/*!
This crate provides an enhanced implementation of the [LZFSE](https://github.com/lzfse/lzfse)
compression library.

### Install

Simply configure your `Cargo.toml`:

```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](std::io::Read) or [Write](std::io::Write) interface.

### Example: compress IO data

This program compresses data from `stdin` into `stdout`. This example can be found in
 `examples/compress_ring.rs`

```no_run
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`

```no_run
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`

```no_run
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`

```no_run
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(())
}
```
*/

mod base;
mod bits;
mod decode;
mod encode;
mod error;
mod fse;
mod kit;
mod lmd;
mod lz;
mod match_kit;
mod ops;
mod raw;
mod ring;
mod types;
mod vn;

#[cfg(test)]
pub mod test_utils;

pub use decode::{decode_bytes, LzfseDecoder, LzfseReader, LzfseReaderBytes, LzfseRingDecoder};
pub use encode::{encode_bytes, LzfseEncoder, LzfseRingEncoder, LzfseWriter, LzfseWriterBytes};
pub use error::{Error, Result};
pub use fse::FseErrorKind;
pub use vn::VnErrorKind;

#[cfg(test)]
mod tests {
    #[test]
    fn test_readme_deps() {
        version_sync::assert_markdown_deps_updated!("README.md");
    }

    #[test]
    fn test_html_root_url() {
        version_sync::assert_html_root_url_updated!("src/lib.rs");
    }
}