12 releases
0.2.3 | Apr 6, 2024 |
---|---|
0.2.2 | Mar 22, 2024 |
0.1.3 | Jan 3, 2024 |
0.1.2 | Dec 15, 2023 |
0.0.0-alpha.0 | Jul 7, 2023 |
#140 in Compression
725 downloads per month
Used in 2 crates
240KB
6K
SLoC
Quick Start
use pco::standalone::{simpler_compress, simple_decompress};
use pco::DEFAULT_COMPRESSION_LEVEL;
use pco::errors::PcoResult;
fn main() -> PcoResult<()> {
// your data
let mut my_ints = Vec::new();
for i in 0..100000 {
my_ints.push(i as i64);
}
// compress
let compressed: Vec<u8> = simpler_compress(&my_ints, DEFAULT_COMPRESSION_LEVEL)?;
println!("compressed down to {} bytes", compressed.len());
// decompress
let recovered = simple_decompress::<i64>(&compressed)?;
println!("got back {} ints from {} to {}", recovered.len(), recovered[0], recovered.last().unwrap());
Ok(())
}
To run something right away, try the benchmarks.
For information about Pco in general, see the main README.
For documentation, docs.rs has the best examples and API details.
API Notes
- In some places, Pco methods accept a destination (either W: Write or &mut [T: NumberLike]). If Pco returns an error, it is possible both the destination and the struct have been modified.
- Pco will always try to process all numbers, and it will fail if insufficient bytes are
available. For instance, during decompression Pco will try to fill the entire
&mut [T]
passed in, returning an insufficient data error if the&[u8]
passed in is not long enough.
Dependencies
~130KB