rust-rbac 0.1.0

A flexible Role-Based Access Control (RBAC) system for Rust applications
Documentation
use async_trait::async_trait;
use crate::error::RbacError;

/// Trait to be implemented by user entities that will have roles and permissions
#[async_trait]
pub trait RbacSubject {
    /// Get the unique identifier for this subject
    fn get_id(&self) -> String;
    
    /// Check if the subject has a specific permission
    async fn has_permission(&self, permission: &str) -> Result<bool, RbacError>;
    
    /// Check if the subject has a specific role
    async fn has_role(&self, role: &str) -> Result<bool, RbacError>;
    
    /// Get all permissions for this subject (both direct and via roles)
    async fn get_permissions(&self) -> Result<Vec<String>, RbacError>;
    
    /// Get all roles for this subject
    async fn get_roles(&self) -> Result<Vec<String>, RbacError>;
}