Skip to main content

Module idents

Module idents 

Source
Expand description

Rust identifier and path construction helpers.

These are shared between buffa’s codegen and downstream code generators (e.g. connectrpc-codegen) that emit Rust code alongside buffa’s message types and need identical keyword-escaping and path-tokenization behavior.

The guarantee is that if buffa generates pub struct r#type::Foo { ... }, downstream callers using rust_path_to_tokens("type::Foo") produce the matching r#type::Foo reference.

Functions§

escape_mod_ident
Escape a proto package segment for use as a Rust mod name.
is_rust_keyword
Is name a Rust keyword (strict, edition-2018+, edition-2024+, or reserved)?
make_field_ident
Create a field identifier, escaping Rust keywords.
rust_path_to_tokens
Parse a ::-separated Rust path string into a TokenStream, using raw identifiers (r#type) for segments that are Rust keywords.