pub struct CSpace {
pub agent_id: Uuid,
pub name: String,
/* private fields */
}Expand description
Capability Space — an agent’s collection of capability tokens.
Inspired by seL4’s CSpace. Each agent has exactly one CSpace that defines what resources it can access and with which rights.
Fields§
§agent_id: UuidThe agent that owns this CSpace.
name: StringHuman-readable name (for display).
Implementations§
Source§impl CSpace
impl CSpace
Sourcepub fn with_name(agent_id: Uuid, name: &str) -> Self
pub fn with_name(agent_id: Uuid, name: &str) -> Self
Create a CSpace with a human-readable name.
Sourcepub fn insert(&mut self, entry: CapabilityEntry) -> u32
pub fn insert(&mut self, entry: CapabilityEntry) -> u32
Insert a capability entry, returning its index.
Sourcepub fn remove(&mut self, index: u32) -> Option<CapabilityEntry>
pub fn remove(&mut self, index: u32) -> Option<CapabilityEntry>
Remove a capability by index.
Sourcepub fn can(&self, resource: &ResourceRef, right: Rights) -> bool
pub fn can(&self, resource: &ResourceRef, right: Rights) -> bool
Check if this CSpace grants right over resource.
Checks for an exact or more-permissive match. For ResourceRef::Path
and ResourceRef::Network, a wildcard pattern (*) matches anything.
Sourcepub fn iter(&self) -> impl Iterator<Item = (&u32, &CapabilityEntry)>
pub fn iter(&self) -> impl Iterator<Item = (&u32, &CapabilityEntry)>
Iterate over all entries.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for CSpace
impl<'de> Deserialize<'de> for CSpace
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for CSpace
impl RefUnwindSafe for CSpace
impl Send for CSpace
impl Sync for CSpace
impl Unpin for CSpace
impl UnsafeUnpin for CSpace
impl UnwindSafe for CSpace
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