Skip to main content

Rights

Struct Rights 

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

Set of rights backed by a u16 bitset.

Each of the 10 rights maps to one bit (bit 0 = Read, …, bit 9 = Declassify). All set operations are O(1) bitwise ops.

Implementations§

Source§

impl Rights

Source

pub const fn empty() -> Rights

Create an empty rights set.

Source

pub const fn all() -> Rights

Create the full rights set containing all 10 rights.

Source

pub const fn singleton(right: Right) -> Rights

Create from a single right.

Source

pub fn from_slice(rights: &[Right]) -> Rights

Create from a slice of rights.

Source

pub const fn from_bits(bits: u16) -> Rights

Create from bitmap representation.

Source

pub const fn read_only() -> Rights

Read-only access rights.

Source

pub fn read_write() -> Rights

Read-write access rights.

Source

pub fn read_write_execute() -> Rights

Read-write-execute access rights.

Source

pub const fn is_empty(&self) -> bool

Check if rights set is empty.

Source

pub const fn len(&self) -> usize

Get the number of rights in the set.

Source

pub const fn contains(&self, right: Right) -> bool

Check if a specific right is present.

Source

pub fn insert(&mut self, right: Right) -> bool

Insert a right into the set. Returns true if the right was not already present.

Source

pub fn remove(&mut self, right: Right) -> bool

Remove a right from the set. Returns true if the right was present.

Source

pub const fn is_subset_of(&self, other: &Rights) -> bool

Subset check: r1 <= r2 iff r1 is subset of r2.

Source

pub const fn is_superset_of(&self, other: &Rights) -> bool

Superset check.

Source

pub const fn combine(&self, other: &Rights) -> Rights

Combine rights via intersection (for delegation – confinement property).

Source

pub const fn intersection(&self, other: &Rights) -> Rights

Alias for combine – intersection of two rights sets.

Source

pub const fn union(&self, other: &Rights) -> Rights

Union of two rights sets.

Source

pub const fn difference(&self, other: &Rights) -> Rights

Difference of two rights sets (self - other).

Source

pub const fn symmetric_difference(&self, other: &Rights) -> Rights

Symmetric difference of two rights sets.

Source

pub const fn complement(&self) -> Rights

Complement (all rights NOT in this set).

Source

pub const fn contains_all(&self, other: &Rights) -> bool

Check if this set contains all rights from another set.

Source

pub const fn contains_any(&self, other: &Rights) -> bool

Check if this set contains any right from another set.

Source

pub const fn with(&self, right: Right) -> Rights

Return a new set with the given right added.

Source

pub const fn without(&self, right: Right) -> Rights

Return a new set with the given right removed.

Source

pub fn to_vec(&self) -> Vec<Right>

Get rights as a Vec (sorted by discriminant order).

Source

pub const fn iter(&self) -> RightsIter ⓘ

Iterate over the rights in the set (sorted by discriminant order).

Source

pub const fn to_bits(&self) -> u16

Convert to bitmap representation.

Trait Implementations§

Source§

impl BitAnd for Rights

Source§

type Output = Rights

The resulting type after applying the & operator.
Source§

fn bitand(self, rhs: Rights) -> Rights

Performs the & operation. Read more
Source§

impl BitAnd for &Rights

Source§

type Output = Rights

The resulting type after applying the & operator.
Source§

fn bitand(self, rhs: &Rights) -> Rights

Performs the & operation. Read more
Source§

impl BitAndAssign for Rights

Source§

fn bitand_assign(&mut self, rhs: Rights)

Performs the &= operation. Read more
Source§

impl BitOr for Rights

Source§

type Output = Rights

The resulting type after applying the | operator.
Source§

fn bitor(self, rhs: Rights) -> Rights

Performs the | operation. Read more
Source§

impl BitOr for &Rights

Source§

type Output = Rights

The resulting type after applying the | operator.
Source§

fn bitor(self, rhs: &Rights) -> Rights

Performs the | operation. Read more
Source§

impl BitOrAssign for Rights

Source§

fn bitor_assign(&mut self, rhs: Rights)

Performs the |= operation. Read more
Source§

impl Clone for Rights

Source§

fn clone(&self) -> Rights

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 Copy for Rights

Source§

impl Debug for Rights

Source§

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

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

impl Default for Rights

Source§

fn default() -> Rights

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

impl Display for Rights

Source§

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

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

impl Eq for Rights

Source§

impl From<Right> for Rights

Source§

fn from(right: Right) -> Rights

Converts to this type from the input type.
Source§

impl FromIterator<Right> for Rights

Source§

fn from_iter<I>(iter: I) -> Rights
where I: IntoIterator<Item = Right>,

Creates a value from an iterator. Read more
Source§

impl Hash for Rights

Source§

fn hash<H>(&self, state: &mut H)
where H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl IntoIterator for Rights

Source§

type Item = Right

The type of the elements being iterated over.
Source§

type IntoIter = RightsIter

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> RightsIter ⓘ

Creates an iterator from a value. Read more
Source§

impl IntoIterator for &Rights

Source§

type Item = Right

The type of the elements being iterated over.
Source§

type IntoIter = RightsIter

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> RightsIter ⓘ

Creates an iterator from a value. Read more
Source§

impl Not for Rights

Source§

type Output = Rights

The resulting type after applying the ! operator.
Source§

fn not(self) -> Rights

Performs the unary ! operation using logical or bitwise negation. Read more
Source§

impl Not for &Rights

Source§

type Output = Rights

The resulting type after applying the ! operator.
Source§

fn not(self) -> Rights

Performs the unary ! operation using logical or bitwise negation. Read more
Source§

impl PartialEq for Rights

Source§

fn eq(&self, other: &Rights) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Rights

Source§

impl Sub for Rights

Source§

type Output = Rights

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Rights) -> Rights

Performs the - operation. Read more
Source§

impl Sub for &Rights

Source§

type Output = Rights

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: &Rights) -> Rights

Performs the - operation. 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> Same for T

Source§

type Output = T

Should always be Self
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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.