pub struct DeclaredRules<'a> { /* private fields */ }Expand description
The #[authorize] rules declared on the matched endpoint.
A zero-allocation view over the route metadata’s AuthorizeRule list — the
framework hands it to IDynamicAuthorizer::authorize_with_rules so a
dynamic backend sees the same literals the endpoint declared (e.g.
#[authorize(permission = "order.create")]), instead of re-deriving the
requirement from route + method.
Multi-rule semantics are AND, preserved here: each item is one
#[authorize] attribute and every item must hold. Within one item, the
role list is any-of and the permission list is any-of; an empty list leaves
that dimension unconstrained, so a rule with both empty means “any
authenticated user”. DeclaredRules::roles and
DeclaredRules::permissions therefore yield one list per rule rather than
a flattened union.
An endpoint without #[authorize] has no rules (DeclaredRules::empty);
a bare #[authorize] has one rule with both lists empty.
New in 1.2.0; additive — authorize keeps its 1.1 signature.
Implementations§
Source§impl<'a> DeclaredRules<'a>
impl<'a> DeclaredRules<'a>
Sourcepub const fn empty() -> DeclaredRules<'a>
pub const fn empty() -> DeclaredRules<'a>
An endpoint with no #[authorize] rule.
Sourcepub const fn new(rules: &'a [AuthorizeRule]) -> DeclaredRules<'a>
pub const fn new(rules: &'a [AuthorizeRule]) -> DeclaredRules<'a>
View over the endpoint’s #[authorize] rules (usually
RouteEntry::authorization).
Sourcepub fn rules(&self) -> &'a [AuthorizeRule]
pub fn rules(&self) -> &'a [AuthorizeRule]
The raw rules — every item must hold (AND).
Sourcepub fn roles(&self) -> impl Iterator<Item = &'a [&'a str]> + 'a
pub fn roles(&self) -> impl Iterator<Item = &'a [&'a str]> + 'a
Declared role lists, one item per #[authorize] rule.
Each item is an any-of list ([] = no role constraint); the items
themselves are ANDed.
Sourcepub fn permissions(&self) -> impl Iterator<Item = &'a [&'a str]> + 'a
pub fn permissions(&self) -> impl Iterator<Item = &'a [&'a str]> + 'a
Declared permission lists, one item per #[authorize] rule.
Each item is an any-of list ([] = no permission constraint); the items
themselves are ANDed.
Trait Implementations§
Source§impl<'a> Clone for DeclaredRules<'a>
impl<'a> Clone for DeclaredRules<'a>
Source§fn clone(&self) -> DeclaredRules<'a>
fn clone(&self) -> DeclaredRules<'a>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl<'a> Copy for DeclaredRules<'a>
Source§impl<'a> Debug for DeclaredRules<'a>
impl<'a> Debug for DeclaredRules<'a>
Source§impl<'a> Default for DeclaredRules<'a>
impl<'a> Default for DeclaredRules<'a>
Source§fn default() -> DeclaredRules<'a>
fn default() -> DeclaredRules<'a>
impl<'a> Eq for DeclaredRules<'a>
Source§impl<'a> PartialEq for DeclaredRules<'a>
impl<'a> PartialEq for DeclaredRules<'a>
impl<'a> StructuralPartialEq for DeclaredRules<'a>
Auto Trait Implementations§
impl<'a> Forget for DeclaredRules<'a>
impl<'a> Freeze for DeclaredRules<'a>
impl<'a> Move for DeclaredRules<'a>
impl<'a> RefUnwindSafe for DeclaredRules<'a>
impl<'a> Send for DeclaredRules<'a>
impl<'a> Sync for DeclaredRules<'a>
impl<'a> Unpin for DeclaredRules<'a>
impl<'a> UnsafeUnpin for DeclaredRules<'a>
impl<'a> UnwindSafe for DeclaredRules<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.