Skip to main content

Ceiling

Enum Ceiling 

Source
pub enum Ceiling {
    Unbounded,
    Scopes(BTreeSet<String>),
}
Expand description

The host’s ceiling for one script: the most it will let that script’s runs touch.

Variants§

§

Unbounded

The host imposes nothing beyond what the script declared and its publisher held.

§

Scopes(BTreeSet<String>)

Exactly these scopes. A grant ending in * admits every scope under that prefix (urn:cap:net:*); a deny-shaped scope (is_deny_scope) is an exclusion every run of the script carries.

Implementations§

Source§

impl Ceiling

Source

pub fn unbounded() -> Ceiling

No ceiling: Ceiling::Unbounded.

Source

pub fn nothing() -> Ceiling

The empty ceiling: the script may touch nothing, not even its language, so it cannot run. The answer for a script the host has no file for, when the host fails closed.

Source

pub fn scoped<I, S>(scopes: I) -> Ceiling
where I: IntoIterator<Item = S>, S: Into<String>,

Exactly these scopes.

Source

pub fn parse(text: &str) -> Result<Ceiling>

Parse the text of a ceiling file (<config home>/script-authority/{name}): one urn:cap: scope per line, # to the end of a line is a comment, blank lines are ignored. A lone * line means Ceiling::Unbounded.

use ikigai_script::authority::Ceiling;
let ceiling = Ceiling::parse(
    "# the nightly report\nurn:cap:lisp\nurn:cap:net:*   # any host\n\
     urn:cap:net:-internal.example\n",
)
.unwrap();
assert!(ceiling.allows("urn:cap:lisp"));
assert!(ceiling.allows("urn:cap:net:example.com"));
assert!(!ceiling.allows("urn:cap:mail:send"));
assert_eq!(ceiling.exclusions(), vec!["urn:cap:net:-internal.example".to_string()]);
assert_eq!(Ceiling::parse("*\n").unwrap(), Ceiling::Unbounded);
assert!(Ceiling::parse("lisp\n").is_err()); // not a capability scope
Source

pub fn allows(&self, scope: &str) -> bool

Whether the ceiling admits the grant scope: held exactly, or under a held prefix* family. An exclusion is never admitted as a grant.

Source

pub fn exclusions(&self) -> Vec<String>

The exclusions the ceiling carries, which every run of the script carries too.

Trait Implementations§

Source§

impl Clone for Ceiling

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 Ceiling

Source§

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

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

impl Eq for Ceiling

Source§

impl PartialEq for Ceiling

Source§

fn eq(&self, other: &Self) -> 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 Ceiling

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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, 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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V