tpt-proto

Rust

Clean-room, pure-Rust implementation of a Protocol Buffers-compatible ecosystem — parser, compiler, codegen, wire-format runtime, reflection, JSON/text formats, and gRPC. MIT OR Apache-2.0.

0 stars0 forks0 watchers

Languages

Rust99.8%Shell0.2%
README

tpt-proto

A clean-room, pure-Rust Protocol Buffers-compatible ecosystem + gRPC layer.

tpt-proto is a Cargo workspace of 15 crates covering the full protobuf stack: a .proto parser (proto2 / proto3 / editions), semantic compiler, Rust code generator, binary wire-format runtime, reflection/dynamic messages, JSON and text-format mappings, well-known types, linting & breaking-change detection, a build.rs integration crate, a CLI toolchain, conformance tooling, and an HTTP/2-based gRPC server/client layer.

Trademark disclaimer. tpt-proto is an independent clean-room implementation. It is not an official Protocol Buffers implementation.

CI License Rust

Quickstart

# Cargo.toml
[dependencies]
tpt-proto-core = "0"      # runtime: encode/decode

[build-dependencies]
tpt-proto-build = "0"     # build-time: .proto -> Rust
// proto/user.proto
syntax = "proto3";
package example;

message User {
  int64 id = 1;
  string name = 2;
}
// build.rs
fn main() {
    tpt_proto_build::compile_protos_simple(
        &["proto/user.proto".into()],
        &["proto".into()],
    )
    .expect("compile protos");
}
// src/main.rs
include!(concat!(env!("OUT_DIR"), "/user.rs"));

fn main() {
    let user = User { id: 42, name: "Ada".into(), ..Default::default() };
    let bytes = user.encode_to_vec().unwrap();
    let back = User::decode(&bytes).unwrap();
    assert_eq!(user, back);
}

Every input .proto and include directory gets cargo:rerun-if-changed emitted automatically — schema edits rebuild without extra wiring.

Documentation

DocumentDescription
QuickstartFrom .proto to running Rust code.
Language supportproto2 / proto3 / editions coverage.
Wire formatBinary encoding details and limits.
Code generationWhat the generator emits; build.rs integration.
JSON mapping · Text formatData interchange formats.
ReflectionDynamic messages via descriptors.
Security limitsDecoder limits, recursion control, fuzzing.
gRPC layerProtocol, security, observability, debugging.
Migrating from prost/tonicSide-by-side conversion guide.
Clean-room policy · LicensingProvenance and legal.

The full index lives in docs/README.md.

Example

examples/grpc-echo is a complete, runnable crate: build.rs generates types + gRPC stubs from proto/greet.proto, and src/main.rs serves and calls them over real TCP HTTP/2:

cargo run -p grpc-echo

Repository layout

crates/        # the 15 workspace crates
docs/          # user & developer documentation
examples/      # runnable end-to-end examples
tests/         # cross-crate integration fixtures
fuzz/          # fuzz targets
benches/       # benchmarks
provenance/    # clean-room provenance records

Contributing & licensing

See CONTRIBUTING.md for the contribution and clean-room/AI-assist policy. Dual-licensed under MIT OR Apache-2.0; copyright TPT Solutions (see COPYRIGHT). Versioning policy: VERSIONING.md.