Skip to main content

CapRoot

Struct CapRoot 

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

The root of all capabilities. Only one can exist per process.

CapRoot has full ambient authority — it can grant any permission. It exists to make authority explicit: every capability in your program traces back to a CapRoot::grant call.

§Example

let root = test_root();
let fs_cap = root.grant::<FsRead>();

Implementations§

Source§

impl CapRoot

Source

pub fn grant<P: Permission>(&self) -> Cap<P>

Grants a capability token for permission P.

The returned Cap<P> is a zero-sized proof that the holder has permission P. This is the only way to obtain a capability token.

§Example
let root = test_root();

// Individual capabilities:
let fs_cap = root.grant::<FsRead>();
let net_cap = root.grant::<NetConnect>();

// Or bundle multiple permissions in one token:
let combo = root.grant::<(FsRead, NetConnect)>();
Source

pub fn fs_read(&self) -> Cap<FsRead>

Grants a Cap<FsRead> for filesystem read access.

Source

pub fn fs_write(&self) -> Cap<FsWrite>

Grants a Cap<FsWrite> for filesystem write access.

Source

pub fn fs_all(&self) -> Cap<FsAll>

Grants a Cap<FsAll> for full filesystem access.

Source

pub fn net_connect(&self) -> Cap<NetConnect>

Grants a Cap<NetConnect> for outbound network connections.

Source

pub fn net_bind(&self) -> Cap<NetBind>

Grants a Cap<NetBind> for binding network listeners.

Source

pub fn net_all(&self) -> Cap<NetAll>

Grants a Cap<NetAll> for full network access.

Source

pub fn env_read(&self) -> Cap<EnvRead>

Grants a Cap<EnvRead> for reading environment variables.

Source

pub fn env_write(&self) -> Cap<EnvWrite>

Grants a Cap<EnvWrite> for writing environment variables.

Source

pub fn spawn(&self) -> Cap<Spawn>

Grants a Cap<Spawn> for subprocess execution.

Source

pub fn ambient(&self) -> Cap<Ambient>

Grants a Cap<Ambient> with full ambient authority.

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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.