pco

Crates.iopco
lib.rspco
version0.2.5
sourcesrc
created_at2023-07-07 23:30:38.285683
updated_at2024-05-06 13:20:17.358521
descriptionGood compression for numerical sequences
homepage
repositoryhttps://github.com/mwlon/pcodec
max_upload_size
id911222
size262,036
Martin (mwlon)

documentation

README

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(())
}

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.
Commit count: 285

cargo fmt