Expand description
Code generator: RBAC YAML → Rust source.
typesec generate --policy rbac.yaml --out src/policy_gen.rs calls
generate_rust and writes the result to a file.
§What gets generated?
For each role in the YAML, the generator emits:
ⓘ
// Auto-generated by typesec-cli — DO NOT EDIT
use typesec_core::role::Role;
pub struct Analyst;
impl Role for Analyst {
fn name() -> &'static str { "analyst" }
fn permission_names() -> &'static [&'static str] { &["read", "read_sensitive"] }
fn resource_patterns() -> &'static [&'static str] { &["reports/*", "metrics/*"] }
}These typed role structs let the compiler verify that the roles you reference in application code actually exist in the policy file. If you rename a role in YAML and regenerate, any code referencing the old name will fail to compile.
Functions§
- generate_
rust - Generate Rust source code for the roles defined in
policy.