Skip to main content

PermissionsDecorator

Struct PermissionsDecorator 

Source
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>

Source

pub fn new(links: L, policy: P, subject: u32) -> Self

links as subject (the null link is a guest) sees it under policy.

Source

pub fn with_created(self, created: HashSet<u32>) -> Self

The same view with the links created before taken as the subject’s own.

Source

pub fn subject(&self) -> u32

The subject the store is seen as.

Source

pub fn set_subject(&mut self, subject: u32)

Source

pub fn created(&self) -> &HashSet<u32>

The links the subject created through this view and still has.

Source

pub fn replace_created(&mut self, created: HashSet<u32>) -> HashSet<u32>

Swaps the links taken as the subject’s own, returning the old ones.

Source

pub fn policy(&self) -> &P

Source

pub fn policy_mut(&mut self) -> &mut P

Source

pub fn inner(&self) -> &L

Source

pub fn inner_mut(&mut self) -> &mut L

Source

pub fn into_inner(self) -> L

Source

pub fn owns(&self, link: &Link) -> bool

Whether link is the subject’s own: created through this view and still without a type.

Source

pub fn can_read(&mut self, link: &Link) -> bool

Whether the subject may read link.

Source

pub fn can_write(&mut self, link: &Link) -> bool

Whether the subject may write link as it is.

Source

pub fn forget(&mut self, index: u32)

The link at index is gone: a new one there is not the subject’s own.

Trait Implementations§

Source§

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

Panics when the subject may not create; use try_ensure_created.

Source§

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>>

The name of any link: names are references.

Source§

fn get_by_name(&mut self, name: &str) -> Result<Option<u32>>

The link of any name: names are references.

Source§

fn try_ensure_created(&mut self, id: u32) -> Result<u32>

Source§

fn exists(&mut self, id: u32) -> bool

Source§

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

Whether a reference of a query to id names a link that exists. Read more
Source§

fn claims(&mut self, id: u32) -> Option<bool>

Whether 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 more
Source§

fn next_created_addresses(&mut self, count: usize) -> Result<Vec<u32>>

The addresses the next count links created in the store get. Read more
Source§

fn update_observed( &mut self, id: u32, source: u32, target: u32, observer: ChangeObserver<'_>, ) -> Result<Link>

Self::update, reporting every change the update caused. Read more
Source§

fn delete_observed( &mut self, id: u32, observer: ChangeObserver<'_>, ) -> Result<Link>

Self::delete, reporting every change the deletion caused. Read more
The links that match a pattern, where None matches any value, in the order of their addresses. Read more
Source§

fn search(&mut self, source: u32, target: u32) -> Option<u32>

Source§

fn set_name(&mut self, id: u32, name: &str) -> Result<u32>

Source§

fn remove_name(&mut self, id: u32) -> Result<()>

Source§

fn save(&mut self) -> Result<()>

Source§

fn try_get_or_create(&mut self, source: u32, target: u32) -> Result<u32>

Self::get_or_create for a layer that may refuse it.
Source§

fn update(&mut self, id: u32, source: u32, target: u32) -> Result<Link>

Source§

fn delete(&mut self, id: u32) -> Result<Link>

Source§

fn get_or_create_named(&mut self, name: &str) -> Result<u32>

Source§

fn format_reference(&mut self, id: u32) -> Result<String>

Source§

fn format_lino(&mut self, link: &Link) -> Result<String>

Source§

fn lino_lines(&mut self) -> Result<Vec<String>>

Source§

fn write_lino_output<P: AsRef<Path>>(&mut self, path: P) -> Result<()>
where Self: Sized,

Source§

fn print_all_lino(&mut self) -> Result<()>

Source§

fn print_change_lino( &mut self, before: &Option<Link>, after: &Option<Link>, ) -> Result<()>

Source§

fn format_structure(&mut self, id: u32) -> Result<String>

Source§

fn format_structure_recursive( &mut self, id: u32, visited: &mut HashSet<u32>, ) -> Result<String>

Auto Trait Implementations§

§

impl<L, P> Freeze for PermissionsDecorator<L, P>
where L: Freeze, P: Freeze,

§

impl<L, P> RefUnwindSafe for PermissionsDecorator<L, P>

§

impl<L, P> Send for PermissionsDecorator<L, P>
where L: Send, P: Send,

§

impl<L, P> Sync for PermissionsDecorator<L, P>
where L: Sync, P: Sync,

§

impl<L, P> Unpin for PermissionsDecorator<L, P>
where L: Unpin, P: Unpin,

§

impl<L, P> UnsafeUnpin for PermissionsDecorator<L, P>
where L: UnsafeUnpin, P: UnsafeUnpin,

§

impl<L, P> UnwindSafe for PermissionsDecorator<L, P>
where L: UnwindSafe, P: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.