pub struct PermissionPolicy { /* private fields */ }Expand description
Permissions stored as links; see the module documentation.
Implementations§
Source§impl PermissionPolicy
impl PermissionPolicy
Sourcepub fn new(
markers: PermissionMarkers,
types: TypeMarkers,
rules: Option<Box<dyn NamedTypeLinks>>,
) -> Self
pub fn new( markers: PermissionMarkers, types: TypeMarkers, rules: Option<Box<dyn NamedTypeLinks>>, ) -> Self
The policy of the rules marked by markers, with the types of
types: in the data when rules is None, else in rules.
Sourcepub fn in_data<L: NamedTypeLinks + ?Sized>(data: &mut L) -> Result<Self>
pub fn in_data<L: NamedTypeLinks + ?Sized>(data: &mut L) -> Result<Self>
The policy of the rules in data, whose points named Type,
Extends, AllowRead, AllowWrite, Anything and AllowReference
are created when missing.
Sourcepub fn with_rules<L: NamedTypeLinks + ?Sized>(
data: &mut L,
rules: Box<dyn NamedTypeLinks>,
) -> Result<Self>
pub fn with_rules<L: NamedTypeLinks + ?Sized>( data: &mut L, rules: Box<dyn NamedTypeLinks>, ) -> Result<Self>
The policy of the rules in rules, a store of their own, over data,
whose points are created when missing as by in_data.
Sourcepub fn types(&self) -> TypeMarkers
pub fn types(&self) -> TypeMarkers
The type markers of the data.
Sourcepub fn rules_mut(&mut self) -> Option<&mut (dyn NamedTypeLinks + 'static)>
pub fn rules_mut(&mut self) -> Option<&mut (dyn NamedTypeLinks + 'static)>
The store of the rules when they are kept apart from the data.
Sourcepub fn rules_of<'a>(
&'a mut self,
data: &'a mut dyn NamedTypeLinks,
) -> &'a mut dyn NamedTypeLinks
pub fn rules_of<'a>( &'a mut self, data: &'a mut dyn NamedTypeLinks, ) -> &'a mut dyn NamedTypeLinks
The store of the rules: data itself, or the rules’ own store.
Sourcepub fn granted(
&mut self,
data: &mut dyn NamedTypeLinks,
marker: u32,
) -> Vec<(u32, u32)>
pub fn granted( &mut self, data: &mut dyn NamedTypeLinks, marker: u32, ) -> Vec<(u32, u32)>
The rules (Subject Object) that marker marks, in the order of their marks.
Sourcepub fn allows(
&mut self,
data: &mut dyn NamedTypeLinks,
marker: u32,
subject: u32,
link: &Link,
) -> bool
pub fn allows( &mut self, data: &mut dyn NamedTypeLinks, marker: u32, subject: u32, link: &Link, ) -> bool
Whether a rule of marker lets subject at link.
Sourcepub fn allow<L: NamedTypeLinks + ?Sized>(
rules: &mut L,
markers: PermissionMarkers,
access: PermissionAccess,
subject: u32,
object: u32,
) -> Result<u32>
pub fn allow<L: NamedTypeLinks + ?Sized>( rules: &mut L, markers: PermissionMarkers, access: PermissionAccess, subject: u32, object: u32, ) -> Result<u32>
Writes a rule into rules: subject may access the links of
object. The rule is the pair (subject object) marked by (marker rule); returns the pair.
Sourcepub fn parse_access(access: &str) -> Result<PermissionAccess>
pub fn parse_access(access: &str) -> Result<PermissionAccess>
Parses read, write or reference.
Trait Implementations§
Source§impl AccessPolicy for PermissionPolicy
impl AccessPolicy for PermissionPolicy
Source§fn markers(&self) -> PermissionMarkers
fn markers(&self) -> PermissionMarkers
Source§fn can_read(
&mut self,
data: &mut dyn NamedTypeLinks,
subject: u32,
link: &Link,
) -> bool
fn can_read( &mut self, data: &mut dyn NamedTypeLinks, subject: u32, link: &Link, ) -> bool
subject may read link; writing allows reading.Source§fn can_write(
&mut self,
data: &mut dyn NamedTypeLinks,
subject: u32,
link: &Link,
) -> bool
fn can_write( &mut self, data: &mut dyn NamedTypeLinks, subject: u32, link: &Link, ) -> bool
subject may write link, as it is or as it will be.Source§fn can_create(&mut self, data: &mut dyn NamedTypeLinks, subject: u32) -> bool
fn can_create(&mut self, data: &mut dyn NamedTypeLinks, subject: u32) -> bool
subject may write anything at all, and so create links.Source§fn can_reference(
&mut self,
data: &mut dyn NamedTypeLinks,
subject: u32,
link: &Link,
) -> bool
fn can_reference( &mut self, data: &mut dyn NamedTypeLinks, subject: u32, link: &Link, ) -> bool
subject may refer to link although it need not read it. A
missing address is asked about as an untyped link. A policy without
this right allows references to readable links only.