pub struct Policy {
pub level: Access,
pub org_class: Option<String>,
}Expand description
An access level, optionally narrowed to organisations of one class.
The grammar is any Access spelling followed by @org_class=<name>:
update = "role:admin" # admins of the active organisation
update = "role:admin@org_class=school" # …but only where it is a school
list = "member@org_class=staff" # any member of a staff organisationAn unqualified policy applies in every organisation, which is what every policy written before classes existed means — so adding classes to an app changes nothing until a policy asks for one.
The class is a filter on the organisation, never a widening: it is checked
in addition to the level, so role:admin@org_class=school is strictly
fewer people than role:admin.
Fields§
§level: AccessWho may act.
org_class: Option<String>The org_class the organisation must carry, if the policy names one.
Implementations§
Source§impl Policy
impl Policy
Sourcepub fn parse(s: &str) -> Policy
pub fn parse(s: &str) -> Policy
Parse "<level>" or "<level>@org_class=<name>".
An empty or malformed class ("role:admin@org_class=") makes the whole
policy private: the same direction a typo in a level takes, because a
qualifier nobody can satisfy must not silently become one everybody can.
Sourcepub fn as_string(&self) -> String
pub fn as_string(&self) -> String
The canonical string form, round-tripping Policy::parse.
Sourcepub fn matches_org_class(&self, class: Option<&str>) -> bool
pub fn matches_org_class(&self, class: Option<&str>) -> bool
Whether an organisation carrying class satisfies this policy’s class
qualifier. An unqualified policy is satisfied by every organisation,
including one with no class at all.
Trait Implementations§
impl Eq for Policy
impl StructuralPartialEq for Policy
Auto Trait Implementations§
impl Freeze for Policy
impl RefUnwindSafe for Policy
impl Send for Policy
impl Sync for Policy
impl Unpin for Policy
impl UnsafeUnpin for Policy
impl UnwindSafe for Policy
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.