arsenal-core · scope
Declared module signatures, types, configuration, and source documentation.
Source: arsenal/crates/arsenal-core/src/scope.rs. SHA-256: 539edaf85c4dd36b2b1c51fd72109798df47809c623318a4b6370e71dab7f46e.
This source reference follows declared modules and preserves feature attributes. It includes public declarations and implementation methods in those modules. Private-module exports and trait resolution still require the compiler; not every declaration is a crate-root import. Function bodies and constant values are omitted. Source comments describe their implementation context and are not a production deployment claim.
scope::Scope
A single permission scope
Format: service:resource:action or service:resource:* for wildcards
Examples:
stripe:charges:readstripe:charges:writegithub:repos:**:*:read(read access to everything)
#[derive(Clone, PartialEq, Eq, Hash, PartialOrd, Ord, Serialize, Deserialize)]
#[serde(transparent)]
pub struct Scope(String);Source line: 29.
scope::Scope::new
Create a new scope with validation
Errors
Returns an error if the scope format is invalid
pub fn new(scope: impl Into<String>) -> ArsenalResult<Self>;Source line: 36.
scope::Scope::wildcard
Create a wildcard scope that matches everything
#[must_use]
pub fn wildcard() -> Self;Source line: 44.
scope::Scope::read_only
Create a read-only scope for a service
#[must_use]
pub fn read_only(service: &str) -> Self;Source line: 50.
scope::Scope::full_access
Create a full access scope for a service
#[must_use]
pub fn full_access(service: &str) -> Self;Source line: 56.
scope::Scope::service
Get the service component
#[must_use]
pub fn service(&self) -> &str;Source line: 62.
scope::Scope::resource
Get the resource component
#[must_use]
pub fn resource(&self) -> &str;Source line: 68.
scope::Scope::action
Get the action component
#[must_use]
pub fn action(&self) -> &str;Source line: 75.
scope::Scope::is_wildcard
Check if this scope is a wildcard (matches everything)
#[must_use]
pub fn is_wildcard(&self) -> bool;Source line: 82.
scope::Scope::implies
Check if this scope implies (covers) another scope
A scope implies another if it grants equal or greater permissions.
Wildcards (*) match any value at that position.
#[must_use]
pub fn implies(&self, other: &Scope) -> bool;Source line: 91.
scope::Scope::as_str
Get the raw scope string
#[must_use]
pub fn as_str(&self) -> &str;Source line: 113.
scope::ScopeSet
A set of scopes representing granted permissions
#[derive(Clone, PartialEq, Eq, Default, Serialize, Deserialize)]
pub struct ScopeSet {
}Source line: 186.
scope::ScopeSet::new
Create an empty scope set
#[must_use]
pub fn new() -> Self;Source line: 193.
scope::ScopeSet::single
Create a scope set with a single scope
#[must_use]
pub fn single(scope: Scope) -> Self;Source line: 201.
scope::ScopeSet::add
Add a scope to the set
Errors
Returns an error if the maximum number of scopes would be exceeded
pub fn add(&mut self, scope: Scope) -> ArsenalResult<()>;Source line: 211.
scope::ScopeSet::remove
Remove a scope from the set
pub fn remove(&mut self, scope: &Scope) -> bool;Source line: 223.
scope::ScopeSet::contains
Check if the set contains a specific scope
#[must_use]
pub fn contains(&self, scope: &Scope) -> bool;Source line: 229.
scope::ScopeSet::allows
Check scope set allows the given scope
Returns true if any scope in the set implies the requested scope
#[must_use]
pub fn allows(&self, requested: &Scope) -> bool;Source line: 237.
scope::ScopeSet::is_superset_of
Check if this scope set is a superset of another
Returns true if all scopes in other are allowed by this set
#[must_use]
pub fn is_superset_of(&self, other: &ScopeSet) -> bool;Source line: 245.
scope::ScopeSet::intersection
Get the intersection of two scope sets
#[must_use]
pub fn intersection(&self, other: &ScopeSet) -> ScopeSet;Source line: 251.
scope::ScopeSet::union
Get the union of two scope sets
#[must_use]
pub fn union(&self, other: &ScopeSet) -> ScopeSet;Source line: 259.
scope::ScopeSet::is_empty
Check if the set is empty
#[must_use]
pub fn is_empty(&self) -> bool;Source line: 267.
scope::ScopeSet::len
Get the number of scopes in the set
#[must_use]
pub fn len(&self) -> usize;Source line: 273.
scope::ScopeSet::iter
Iterate over the scopes
pub fn iter(&self) -> impl Iterator<Item = &Scope>;Source line: 278.
scope::ScopeSet::to_strings
Convert to a vector of scope strings
#[must_use]
pub fn to_strings(&self) -> Vec<String>;Source line: 284.
scope::ScopeSet::from_strings
Create from a vector of scope strings
Errors
Returns an error if any scope is invalid or too many scopes are provided
pub fn from_strings(scopes: Vec<String>) -> ArsenalResult<Self>;Source line: 292.
scope::Permission
Permission type for CRUD operations
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[serde(rename_all = "lowercase")]
pub enum Permission {
/// Read/view access
Read,
/// Create new resources
Create,
/// Update existing resources
Update,
/// Delete resources
Delete,
/// Full access (all permissions)
Admin,
}Source line: 339.
scope::Permission::as_str
Get the string representation
#[must_use]
pub const fn as_str(&self) -> &'static str;Source line: 355.
scope::Permission::implies
Check if this permission implies another
#[must_use]
pub const fn implies(&self, other: &Permission) -> bool;Source line: 367.