rust_rbac/models/
role.rs

1use serde::{Serialize, Deserialize};
2
3/// Represents a role in the system
4#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
5pub struct Role {
6    /// Unique name of the role (e.g., "editor")
7    pub name: String,
8    
9    /// Optional human-readable description
10    pub description: Option<String>,
11}
12
13impl Role {
14    pub fn new(name: impl Into<String>) -> Self {
15        Self {
16            name: name.into(),
17            description: None,
18        }
19    }
20    
21    pub fn with_description(name: impl Into<String>, description: impl Into<String>) -> Self {
22        Self {
23            name: name.into(),
24            description: Some(description.into()),
25        }
26    }
27}