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

Download history 7/week @ 2023-12-29 2/week @ 2024-01-05 1/week @ 2024-01-19 16/week @ 2024-01-26 16/week @ 2024-02-02 15/week @ 2024-02-09 46/week @ 2024-02-16 46/week @ 2024-02-23 20/week @ 2024-03-01 29/week @ 2024-03-08 320/week @ 2024-03-15 213/week @ 2024-03-22 55/week @ 2024-03-29 133/week @ 2024-04-05

725 downloads per month
Used in 2 crates

Apache-2.0

240KB
6K SLoC

Crates.io

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