Function get_role_permissions

Source
pub async fn get_role_permissions(
    pool: &Pool<MySql>,
    role_id: i64,
) -> Result<Vec<Permission>>
Expand description

Retrieves all permissions associated with a specific role.

This function fetches all permissions that have been assigned to a given role. It’s useful for displaying role capabilities or checking the full set of permissions granted by a particular role.

§Arguments

  • pool - Database connection pool for executing the query
  • role_id - Unique identifier of the role whose permissions to retrieve

§Returns

  • Ok(Vec<Permission>) - Successfully retrieved list of permissions for the role
  • Err(anyhow::Error) - Failed to fetch role permissions

§Query Details

This function performs a JOIN operation between the permissions and permissions_role tables to find all permissions associated with the specified role.