bytepeel-core
The library behind bytepeel: a recursive decoder and editor for encoded and binary data, with no dependencies by default.
It peels input layer by layer into a tree: hex, base64, PEM (and bundles),
JWTs, xxd/hexdump -C dumps, gzip/zlib/zstd (optional features), DER/ASN.1,
CBOR, MessagePack and schemaless protobuf, nested in any order. Every node
carries its byte range. Where the bytes are genuinely ambiguous (is a protobuf
LEN field a string, a submessage or packed varints?), the top interpretations
are kept with scores instead of one being picked silently.
use ;
let opts = default;
// base64 -> protobuf -> a string field that is base64 again -> text.
let node = peel.unwrap;
println!; // the whole tree as JSON
// Select one item by path (paths can cross formats, e.g. into a
// certificate held in a protobuf field).
match get.unwrap
// Edit and re-encode every layer in its original style (here: hex).
let out = edit.unwrap;
assert_eq!;
Features
| Feature | Adds | Dependency |
|---|---|---|
deflate |
gzip and zlib layers | miniz_oxide |
zstd |
Zstandard layers | ruzstd |
Both are off by default and pure Rust. The crate has no unsafe code.
The JSON schema, paths, heuristics and error codes are specified in DESIGN.md.
License
MIT