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 new(rules: &'a [AuthorizeRule]) -> Self
pub const fn new(rules: &'a [AuthorizeRule]) -> Self
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.