pub struct PermissionsDecorator<L: NamedTypeLinks, P: AccessPolicy = PermissionPolicy> { /* private fields */ }Expand description
The store as one subject sees it; see the module documentation.
Reads skip the links the subject may not read, so a hidden link is as
missing as a deleted one: to exists, to
get_link, and to every write, which answers
Link not found. A write the subject may not make fails with
Forbidden and changes nothing. An update needs the right to write the
link before and after it.
A link the subject created through this view is its own while it has no
type (its source is 0), so it can give it one. forget
drops that claim when the link is gone.
The store below may change more than the link asked for: deleting a link deletes the links that use it, and an update that makes a link equal to another merges them, repointing the usages. Every link a write changes must be the subject’s to change; when one is not, the write is undone and refused as a whole.
Names are references, not links: get_name
and get_by_name answer for every link, so
a subject may refer to a type it cannot read. Naming or unnaming a link
needs the right to write it.
A reference of a query is checked in the store below
(reference_exists): a hidden link is
not found, yet its address is taken, so a query cannot learn that it is
taken by trying to create a link there.
Implementations§
Source§impl<L: NamedTypeLinks, P: AccessPolicy> PermissionsDecorator<L, P>
impl<L: NamedTypeLinks, P: AccessPolicy> PermissionsDecorator<L, P>
Sourcepub fn new(links: L, policy: P, subject: u32) -> Self
pub fn new(links: L, policy: P, subject: u32) -> Self
links as subject (the null link is a guest) sees it under policy.
Sourcepub fn with_created(self, created: HashSet<u32>) -> Self
pub fn with_created(self, created: HashSet<u32>) -> Self
The same view with the links created before taken as the subject’s own.
pub fn set_subject(&mut self, subject: u32)
Sourcepub fn created(&self) -> &HashSet<u32>
pub fn created(&self) -> &HashSet<u32>
The links the subject created through this view and still has.
Sourcepub fn replace_created(&mut self, created: HashSet<u32>) -> HashSet<u32>
pub fn replace_created(&mut self, created: HashSet<u32>) -> HashSet<u32>
Swaps the links taken as the subject’s own, returning the old ones.
pub fn policy(&self) -> &P
pub fn policy_mut(&mut self) -> &mut P
pub fn inner(&self) -> &L
pub fn inner_mut(&mut self) -> &mut L
pub fn into_inner(self) -> L
Trait Implementations§
Source§impl<L: NamedTypeLinks, P: AccessPolicy> NamedTypeLinks for PermissionsDecorator<L, P>
impl<L: NamedTypeLinks, P: AccessPolicy> NamedTypeLinks for PermissionsDecorator<L, P>
Source§fn create(&mut self, source: u32, target: u32) -> u32
fn create(&mut self, source: u32, target: u32) -> u32
Panics when the subject may not create; use
try_create.
Source§fn ensure_created(&mut self, id: u32) -> u32
fn ensure_created(&mut self, id: u32) -> u32
Panics when the subject may not create; use
try_ensure_created.
Source§fn get_or_create(&mut self, source: u32, target: u32) -> u32
fn get_or_create(&mut self, source: u32, target: u32) -> u32
Panics when the subject may not create; use
try_get_or_create.
Source§fn get_name(&mut self, id: u32) -> Result<Option<String>>
fn get_name(&mut self, id: u32) -> Result<Option<String>>
The name of any link: names are references.
Source§fn get_by_name(&mut self, name: &str) -> Result<Option<u32>>
fn get_by_name(&mut self, name: &str) -> Result<Option<u32>>
The link of any name: names are references.
fn try_ensure_created(&mut self, id: u32) -> Result<u32>
fn get_link(&mut self, id: u32) -> Option<Link>
fn exists(&mut self, id: u32) -> bool
Source§fn try_create(&mut self, source: u32, target: u32) -> Result<u32>
fn try_create(&mut self, source: u32, target: u32) -> Result<u32>
Self::create for a layer that may refuse it, as a
PermissionsDecorator
does: the query processor and the type hierarchy create through it.Source§fn reference_exists(&mut self, id: u32) -> bool
fn reference_exists(&mut self, id: u32) -> bool
id names a link that exists. Read moreSource§fn claims(&mut self, id: u32) -> Option<bool>
fn claims(&mut self, id: u32) -> Option<bool>
id is an address of this store, so a link created there
(Self::ensure_created, the undo of a delete) belongs in it; None
for a plain store, which has no addresses of its own. Read moreSource§fn next_created_addresses(&mut self, count: usize) -> Result<Vec<u32>>
fn next_created_addresses(&mut self, count: usize) -> Result<Vec<u32>>
count links created in the store get. Read moreSource§fn update_observed(
&mut self,
id: u32,
source: u32,
target: u32,
observer: ChangeObserver<'_>,
) -> Result<Link>
fn update_observed( &mut self, id: u32, source: u32, target: u32, observer: ChangeObserver<'_>, ) -> Result<Link>
Self::update, reporting every change the update caused. Read moreSource§fn delete_observed(
&mut self,
id: u32,
observer: ChangeObserver<'_>,
) -> Result<Link>
fn delete_observed( &mut self, id: u32, observer: ChangeObserver<'_>, ) -> Result<Link>
Self::delete, reporting every change the deletion caused. Read morefn all_links(&mut self) -> Vec<Link> ⓘ
Source§fn query_links(
&mut self,
index: Option<u32>,
source: Option<u32>,
target: Option<u32>,
) -> Vec<Link> ⓘ
fn query_links( &mut self, index: Option<u32>, source: Option<u32>, target: Option<u32>, ) -> Vec<Link> ⓘ
None matches any value, in
the order of their addresses. Read morefn search(&mut self, source: u32, target: u32) -> Option<u32>
fn set_name(&mut self, id: u32, name: &str) -> Result<u32>
fn remove_name(&mut self, id: u32) -> Result<()>
fn save(&mut self) -> Result<()>
Source§fn try_get_or_create(&mut self, source: u32, target: u32) -> Result<u32>
fn try_get_or_create(&mut self, source: u32, target: u32) -> Result<u32>
Self::get_or_create for a layer that may refuse it.fn update(&mut self, id: u32, source: u32, target: u32) -> Result<Link>
fn delete(&mut self, id: u32) -> Result<Link>
fn get_or_create_named(&mut self, name: &str) -> Result<u32>
fn format_reference(&mut self, id: u32) -> Result<String>
fn format_lino(&mut self, link: &Link) -> Result<String>
fn lino_lines(&mut self) -> Result<Vec<String>>
fn write_lino_output<P: AsRef<Path>>(&mut self, path: P) -> Result<()>where
Self: Sized,
fn print_all_lino(&mut self) -> Result<()>
fn print_change_lino( &mut self, before: &Option<Link>, after: &Option<Link>, ) -> Result<()>
fn format_structure(&mut self, id: u32) -> Result<String>
fn format_structure_recursive( &mut self, id: u32, visited: &mut HashSet<u32>, ) -> Result<String>
Source§impl<L: Triplets, P: AccessPolicy> Triplets for PermissionsDecorator<L, P>
impl<L: Triplets, P: AccessPolicy> Triplets for PermissionsDecorator<L, P>
Source§fn triplet_markers(&self) -> TripletMarkers
fn triplet_markers(&self) -> TripletMarkers
Source§fn role_of(&mut self, id: u32) -> Option<DoubletRole>
fn role_of(&mut self, id: u32) -> Option<DoubletRole>
id is in the encoding; None when it is missing.Source§fn create_triplet_point(&mut self) -> Result<u32>
fn create_triplet_point(&mut self) -> Result<u32>
(i: i 0 0) that is its own type: the root of a
hierarchy has to start somewhere.Source§fn create_triplet_point_at(&mut self, address: u32) -> Result<()>
fn create_triplet_point_at(&mut self, address: u32) -> Result<()>
(address: address 0 0) at an address nothing uses,
the way a substitution query defines a triplet at an address it names.Source§fn update_triplet(
&mut self,
index: u32,
type_id: u32,
from: u32,
to: u32,
) -> Result<Triplet>
fn update_triplet( &mut self, index: u32, type_id: u32, from: u32, to: u32, ) -> Result<Triplet>
index (index: type from to), keeping its
address, and returns the triplet as it was. Read moreSource§fn delete_triplet(&mut self, index: u32) -> Result<Vec<Triplet>>
fn delete_triplet(&mut self, index: u32) -> Result<Vec<Triplet>>
index and every triplet that uses a deleted
one as its type, from or to; returns them all, index first. Read moreSource§fn each_triplet(&mut self, query: TripletQuery) -> Vec<Triplet>
fn each_triplet(&mut self, query: TripletQuery) -> Vec<Triplet>
query, in the order of their addresses. Read moreSource§fn get_triplet(&mut self, index: u32) -> Option<Triplet>
fn get_triplet(&mut self, index: u32) -> Option<Triplet>
index, None when index is not a triplet.Source§fn is_triplet(&mut self, index: u32) -> bool
fn is_triplet(&mut self, index: u32) -> bool
index is a triplet.Source§fn count_triplets(&mut self, query: TripletQuery) -> usize
fn count_triplets(&mut self, query: TripletQuery) -> usize
query.Source§fn doublet_usages(&mut self, id: u32) -> usize
fn doublet_usages(&mut self, id: u32) -> usize
id as their source or target.