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
impl CapRoot
Sourcepub fn grant<P: Permission>(&self) -> Cap<P>
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)>();Sourcepub fn net_connect(&self) -> Cap<NetConnect>
pub fn net_connect(&self) -> Cap<NetConnect>
Grants a Cap<NetConnect> for outbound network connections.
Sourcepub fn env_read(&self) -> Cap<EnvRead>
pub fn env_read(&self) -> Cap<EnvRead>
Grants a Cap<EnvRead> for reading environment variables.
Auto Trait Implementations§
impl Freeze for CapRoot
impl RefUnwindSafe for CapRoot
impl Send for CapRoot
impl Sync for CapRoot
impl Unpin for CapRoot
impl UnsafeUnpin for CapRoot
impl UnwindSafe for CapRoot
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more