precomp2 is a Rust library for reversible preprocessing of compressed and container data. It turns recognizable streams into PCF2 segments that are easier for an outer compressor to handle, then restores the original bytes exactly.
The project is inspired by precomp-cpp and preflate-rs.
- Lossless encode/decode APIs for byte slices and async decode input.
- PCF2 segment container with literal, nested, DEFLATE, zlib, gzip, PNG IDAT, JPEG, Base64, bzip2, and PDF Flate segment kinds.
- Recursive preprocessing with depth and output budget limits.
- Optional PNG WebP, PDF predictor, and PDF bitmap fallback transforms behind
EncodeConfigflags.
use precomp2::{DecodeConfig, EncodeConfig};
fn main() -> precomp2::Result<()> {
let input = b"payload";
let encoded = precomp2::encode_bytes(input, &EncodeConfig::default())?;
let decoded = precomp2::decode_bytes(&encoded, &DecodeConfig::default())?;
assert_eq!(decoded, input);
Ok(())
}This crate is early-stage. The on-disk PCF2 format should be treated as unstable until a 1.0 release.
Licensed under the Apache License, Version 2.0.