buffa
The runtime crate for buffa — a pure-Rust Protocol Buffers implementation
with first-class editions support, zero-copy views, and no_std compatibility.
This crate contains the Message trait, wire-format encode/decode primitives,
MessageField / EnumValue / UnknownFields container types, and the
zero-copy view layer. Generated code emitted by buffa-build or
protoc-gen-buffa depends on this crate.
Quick start
See the workspace README for end-to-end setup with buf generate or
build.rs. In short:
use Message;
let bytes = person.encode_to_vec;
let decoded = decode_from_slice?;
For untrusted input, tighten limits with DecodeOptions:
use DecodeOptions;
let msg: Person = new
.with_recursion_limit
.with_max_message_size // 1 MiB
.decode_from_slice?;
Feature flags
| Flag | Default | Enables |
|---|---|---|
std |
✓ | std::io::Read decoders, HashMap for map fields, thread-local JSON parse options |
json |
Proto3 JSON via serde |
|
arbitrary |
arbitrary::Arbitrary impls for fuzzing |
With default-features = false the crate is #![no_std] (requires alloc).
Documentation
- API reference: https://docs.rs/buffa
- User guide: docs/guide.md
- Design rationale: DESIGN.md
Conformance
buffa passes the full protobuf conformance suite for binary and JSON encoding
(both std and no_std builds). Text format (textproto) is not supported.
License
Apache-2.0