capnpack
This is an implementation of CapnProto's packing algorithm in pure Rust. Along with a few slight modifications to allow the algorithm to work for any binary payload of any size.
Usage
// Packing:
let data = vec!;
let packed = pack;
// Un-packing:
let packed = vec!;
let unpacked_data = unpack.unwrap; // size hint can be any reasonable number
assert_eq!;
Note: Data packed by this library may not be compatible with other implementations of CapnProto's packing algorithm due to slight modifications to the algorithm to allow for any sized payloads.
Modifications to the packing algorithm
If the input data to the packing algorithm does not align to a multiple of 8 bytes, and is compressible via the typical format. Then the remaining data is processed via the typical packing process, but with the corresponding places for the missing bytes set to 1.
Ex: Say we have data 0, 0, 1, 2, 0
The tag will be: 0b 111 01100. 01100 is the normal packing algorithm, and the 111 is the filler 1s for the missing bytes.
This data packed will be: 0b11101100, 1, 2.
This allows the decoder/unpacker to know when to stop processing without any additional overhead.
License & Contribution
This repository is licensed under the MIT license. See license.md.
Any and all contributions are welcome. If you encounter a problem, please open an issue.