validate_permissions

Macro validate_permissions 

Source
macro_rules! validate_permissions {
    ($($permission:expr),* $(,)?) => { ... };
}
Expand description

Macro for test-time permission validation.

This macro validates that the provided permission strings don’t have hash collisions by generating a test that runs during cargo test. It should be called once in your application with all the permission strings you use.

The macro accepts both square brackets and parentheses syntax.

§Examples


// Using square brackets (recommended style)
validate_permissions![
    "read:users",
    "write:users",
    "delete:users",
    "admin:system"
];

// Using parentheses (also valid)
validate_permissions!(
    "read:posts",
    "write:posts",
    "delete:posts"
);

// Mixed permission types
validate_permissions![
    "api:read",
    "api:write",
    "admin:users",
    "admin:system",
    "billing:read",
    "billing:write"
];

§Panics

This macro will cause a test failure if any of the permission strings hash to the same value (extremely unlikely with SHA-256).