Skip to main content

RightsSchema

Struct RightsSchema 

Source
pub struct RightsSchema { /* private fields */ }
Expand description

The rights one type of item has, by name, and the aliases that stand for several.

A right is one bit, numbered in the order it is defined. An alias names a set of rights and earlier aliases: Windows generic rights, NFSv4 basic permissions and Proxmox roles are all aliases. A cancelling name (RightsSchemaBuilder::cancel) grants nothing, and an entry naming it denies everything (Proxmox’s NoAccess).

use coqui_access_acl::RightsSchema;

let schema = RightsSchema::builder()
    .right("read_data")
    .right("read_attributes")
    .right("write_data")
    .alias("read", ["read_data", "read_attributes"])
    .build()?;
assert_eq!(schema.rights(["read"])?, schema.rights(["read_data", "read_attributes"])?);
assert!(schema.rights(["delete"]).is_err());

Implementations§

Source§

impl RightsSchema

Source

pub fn builder() -> RightsSchemaBuilder

Starts a schema; rights take bits in the order they are added.

Source

pub fn len(&self) -> usize

How many rights (bits) the schema defines; aliases are not counted.

Source

pub fn is_empty(&self) -> bool

Whether the schema defines no right.

Source

pub fn bit(&self, name: &str) -> Option<usize>

The bit of the right name; None for an alias or an unknown name.

Source

pub fn all(&self) -> Rights

Every right the schema defines.

Source

pub fn cancels(&self, name: &str) -> bool

Whether name cancels everything.

Source

pub fn rights<I, S>(&self, names: I) -> Result<Rights, AclError>
where I: IntoIterator<Item = S>, S: AsRef<str>,

The rights names stand for together: rights and aliases, unioned.

§Errors

AclError::UnknownRight with the position of the first name the schema lacks.

Source

pub fn names<'a>(&'a self, rights: &Rights) -> Vec<&'a str>

The names of the rights in rights, lowest bit first; a bit the schema does not define is left out.

Trait Implementations§

Source§

impl Clone for RightsSchema

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for RightsSchema

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for RightsSchema

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.