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
//!Rust Compression library with generic interface
//!
//!## API
//!
//!API is mostly thin layer that provides uniform behavior for all algorithms the best it can.
//!
//!Please read documentation to see how to use:
//!
//!- [Decoder](decoder/struct.Decoder.html)
//!- [Encoder](encoder/struct.Encoder.html)
//!
//!## Features
//!
//!All features are off by default.
//!This crate requires `alloc` to be available with system allocator set.
//!
//!- `brotli-c` - Enables `brotli` interface using C library.
//!- `brotli-rust` - Enables `brotli` interface using pure Rust library.
//!- `zlib` - Enables `zlib` interface.
//!- `zlib-static` - Enables `zlib` interface with `static` feature.
//!- `zlib-ng` - Enables `zlib-ng` interface.
//!- `zlib-rust` - Enables `zlib-rs` interface.
//!- `zstd` - Enables `zstd` interface.
//!- `bytes` - Enables `bytes` support
//!
//!## Usage
//!
//!### Decode
//!
//!Minimal example of using Decoder.
//!Use [Interface](decoder/struct.Interface.html) to create instance.
//!
//!If you unsure about compression used, you can try [detect](decoder/enum.Detection.html#method.detect) it
//!
//!```rust,no_run
//!use compu::{Decoder, DecodeStatus, DecodeError};
//!
//!fn example(decoder: &mut Decoder, input: &[u8]) -> Result<Vec<u8>, DecodeError> {
//! let mut output = Vec::with_capacity(1024);
//! loop {
//! let result = decoder.decode_vec(input, &mut output).status?;
//! match result {
//! DecodeStatus::NeedInput => panic!("Not enough input, incomplete data?"),
//! //If you need more output, please allocate spare capacity.
//! //API never allocates, only you allocate
//! DecodeStatus::NeedOutput => output.reserve(1024),
//! DecodeStatus::Finished => {
//! //Make sure to reset state, if you want to re-use decoder.
//! decoder.reset();
//! break Ok(output)
//! }
//! }
//! }
//!}
//!```
//!
//!### Encode
//!
//!Minimal example of using Encoder.
//!Use [Interface](encoder/struct.Interface.html) to create instance.
//!
//!```rust,no_run
//!use compu::{Encoder, EncodeStatus, EncodeOp};
//!
//!fn example(encoder: &mut Encoder, input: &[u8]) -> Vec<u8> {
//! let mut output = Vec::with_capacity(1024);
//! loop {
//! let result = encoder.encode_vec(input, &mut output, EncodeOp::Finish).status;
//! match result {
//! //This status is returned by any other `EncodeOp` except `Finish
//! EncodeStatus::Continue => panic!("I wanted to finish but continue!?"),
//! //If you need more output, please allocate spare capacity.
//! //API never allocates, only you allocate
//! EncodeStatus::NeedOutput => output.reserve(1024),
//! //If you have enough space, `EncodeOp::Finish` will result in this operation
//! EncodeStatus::Finished => {
//! //Make sure to reset state, if you want to re-use it.
//! encoder.reset();
//! break output;
//! }
//! //Generally can indicate internal error likely due to OOM condition.
//! //Note that all wrappers ensure that Rust's global allocator is used,
//! //so take care if you use custom one
//! //Generally should not happen, so it is ok to just panic
//! //but be a good boy and return error properly if it happens, even if it is unlikely
//! EncodeStatus::Error => {
//! panic!("unlikely")
//! }
//! }
//! }
//!}
//!```
pub
pub use ;
pub use ;
pub use Buffer;