Skip to content

About

Generate Rust query helpers for protobuf-orm entities.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

protoc-gen-orm-rust

Generate Rust lookup helpers for protobuf-orm entities from the service contracts produced by protoc-gen-orm-service. The plugin runs on the build host. Its output uses Buffa messages and Connect Rust services on native and browser WASM targets.

For a tenant-scoped unique index, the generated API takes the index fields in declaration order:

let request = UserRef::by_alias("sam".into(), TenantRef::by_id(2)).pick();
let router = register_user_service(connectrpc::Router::new(), directory);

Generate

Install the executable with go install github.com/protobuf-orm/protoc-gen-orm-rust@main. Generate the ORM service protos first, then pass the entity and service files through Buffa, Connect Rust and this plugin. The example Buf configuration shows the plugin order and package layout. Import the Buffa modules under crate::proto and the Connect modules under crate::services. Include each emitted *.orm.rs in the same Rust crate as the messages.

For each ORM entity with a generated Get service, the plugin emits constructors for its key oneof, pick, optional with_select, and a router registration function. This first implementation handles scalar keys and composite keys containing scalars or top-level message references. Enum and nested message keys report a generation error. Database schema, CRUD implementations, and Payday policy are separate layers.

For a storage generator, run the plugin a second time with opt: [storage_model] and strategy: all. Its model.json records resolved key types, field presence, defaults, immutability, relation targets, version and erase markers, and ordered compound indexes. The graph is shared with the upstream ORM service generator. The versioned output is deterministic across input orders. Directory model

Test

go test ./... tests descriptor handling. The directory example exercises generated code with Diesel SQLite. The same Rust router serves a native Connect endpoint and a WASM Worker reached with the published TypeScript dRPC transport.

About

Generate Rust query helpers for protobuf-orm entities.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages