Pure Rust schema-less Protocol Buffers encoder and decoder. It infers a reusable type definition from unknown protobuf bytes and can re-encode edited values.
This crate is an independent Rust port based on the concepts, public API,
typedef semantics, and wire behavior of NCC Group's original
nccgroup/blackboxprotobuf
project. The original project is Copyright (c) 2018-2023 NCC Group Plc and is
distributed under the MIT License. This port is not an official NCC Group
release and is not endorsed by NCC Group.
use blackboxprotobuf::{decode_message, encode_message};
let bytes = [0x08, 0x7b, 0x12, 0x05, b'A', b'l', b'i', b'c', b'e'];
let (message, typedef) = decode_message(&bytes, None)?;
assert_eq!(encode_message(&message, &typedef)?, bytes);
# Ok::<(), blackboxprotobuf::Error>(())Supported types include all blackboxprotobuf integer/fixed/float types,
strings, bytes, embedded messages, repeated values, packed values, alternate
type definitions, field names, field-order preservation, and gRPC gzip frames.
Enable Rust-side gzip compression with the opt-in gzip Cargo feature; plain
gRPC framing is available with default features.
See NOTICE for the upstream relationship and attribution details.