pub struct CSpace {
pub agent_id: AgentId,
/* private fields */
}Expand description
An agent’s capability space: the complete set of capabilities it holds.
The CSpace is a HashMap<CapabilityId, Capability>. When the
AccessManager checks whether an agent may perform an action, it
scans the agent’s CSpace for a capability matching the target
resource with sufficient rights.
Fields§
§agent_id: AgentIdThe agent that owns this capability space.
Implementations§
Source§impl CSpace
impl CSpace
Sourcepub fn insert(&mut self, cap: Capability) -> Option<Capability>
pub fn insert(&mut self, cap: Capability) -> Option<Capability>
Inserts a capability into this space, returning the old one if replaced.
Sourcepub fn remove(&mut self, id: &CapabilityId) -> Option<Capability>
pub fn remove(&mut self, id: &CapabilityId) -> Option<Capability>
Removes a capability by ID.
Sourcepub fn get(&self, id: &CapabilityId) -> Option<&Capability>
pub fn get(&self, id: &CapabilityId) -> Option<&Capability>
Looks up a capability by ID.
Sourcepub fn can(&self, resource: &ResourceRef, required: Rights) -> bool
pub fn can(&self, resource: &ResourceRef, required: Rights) -> bool
Returns true if any capability in this space matches the resource and grants the requested rights.
Sourcepub fn iter(&self) -> impl Iterator<Item = &Capability>
pub fn iter(&self) -> impl Iterator<Item = &Capability>
Returns an iterator over all capabilities in this space.
Sourcepub fn retain(&mut self, pred: impl Fn(&Capability) -> bool)
pub fn retain(&mut self, pred: impl Fn(&Capability) -> bool)
Retains only capabilities for which pred returns true.
Sourcepub fn filter_resource(
&self,
f: impl Fn(&ResourceRef) -> bool,
) -> Vec<&Capability>
pub fn filter_resource( &self, f: impl Fn(&ResourceRef) -> bool, ) -> Vec<&Capability>
Returns capabilities matching a specific resource type filter.
Sourcepub fn active_domains(&self) -> Vec<&str>
pub fn active_domains(&self) -> Vec<&str>
Returns the unique kernel domain names active in this CSpace.
Useful for building a kernel manifest for the system prompt.