Skip to main content

Crate qm_role_build

Crate qm_role_build 

Source
Expand description

Role builder from markdown tables.

This crate provides utilities to generate Rust code for role-based access control (RBAC) from markdown tables defined in documentation. It parses markdown files containing user groups and role mappings, then generates Rust code that can be used in your application.

§Input Format

The input markdown file should contain two tables:

  1. User Groups Table - defines available user groups and their paths
  2. Role Mappings Table - maps user groups to roles

§Example Input

```markdown

§User Groups user_groups

NamePathDisplay NameAllowed Types
Admin/administration_ownerAdminnone
CustomerOwner/customer_ownerOwner of Customernone

§Role Mappings roles

RolesAdminInstitutionOwnerReader
administrationx
user:listx
```

§Usage

use qm_role_build::generate;

fn main() -> anyhow::Result<()> {
    generate("path/to/roles.md")?;
    Ok(())
}

§Output

The generated code creates a RoleMapping struct containing the user group to roles mapping that can be used for authorization decisions.

Functions§

generate
Generate role mapping code from a markdown file.
generate_to_writer
Generate role mapping code to a custom writer.