Skip to main content

Role

Trait Role 

Source
pub trait Role:
    Send
    + Sync
    + 'static {
    const NAME: &'static str;

    // Provided method
    fn held_by(admin: &Admin, user_id: &Id, role: Option<&str>) -> bool { ... }
}
Expand description

A role a route can require, named as it is stored in user.role. Implement it with role!.

Required Associated Constants§

Source

const NAME: &'static str

The role’s name: "admin", "support".

Provided Methods§

Source

fn held_by(admin: &Admin, user_id: &Id, role: Option<&str>) -> bool

Whether a user with this id and user.role value holds the role. Default: Admin::has_role with NAME.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl Role for Admin

Source§

const NAME: &'static str = "admin"

Source§

impl Role for User

Source§

const NAME: &'static str = "user"