pub struct Capability {
pub id: CapabilityId,
pub name: String,
pub schubert_class: SchubertClass,
pub requires: Vec<CapabilityId>,
pub conflicts: Vec<CapabilityId>,
}Expand description
A capability in ShaperOS: an incidence condition on namespaces
Capabilities represent access rights that can be granted to namespaces. Each capability corresponds to a Schubert class, representing the geometric condition that a namespace must satisfy to have that capability.
§Contracts
- The Schubert class must be valid for the given Grassmannian
- Dependencies form a DAG (no cycles)
- Conflicts are symmetric (if A conflicts with B, B should conflict with A)
Fields§
§id: CapabilityIdUnique identifier
name: StringHuman-readable name
schubert_class: SchubertClassSchubert class representing the incidence condition “Namespaces with this capability” = Schubert variety σ_λ
requires: Vec<CapabilityId>Dependencies: must have these capabilities first
conflicts: Vec<CapabilityId>Conflicts: cannot coexist with these
Implementations§
Source§impl Capability
impl Capability
Sourcepub fn new(
id: impl Into<String>,
name: impl Into<String>,
partition: Vec<usize>,
grassmannian: (usize, usize),
) -> EnumerativeResult<Self>
pub fn new( id: impl Into<String>, name: impl Into<String>, partition: Vec<usize>, grassmannian: (usize, usize), ) -> EnumerativeResult<Self>
Create a new capability
§Contract
requires: partition fits in Grassmannian box
ensures: result.codimension() == partition.iter().sum()Sourcepub fn requires(self, cap_id: CapabilityId) -> Self
pub fn requires(self, cap_id: CapabilityId) -> Self
Add a dependency (builder pattern)
Sourcepub fn requires_all(
self,
cap_ids: impl IntoIterator<Item = CapabilityId>,
) -> Self
pub fn requires_all( self, cap_ids: impl IntoIterator<Item = CapabilityId>, ) -> Self
Add multiple dependencies
Sourcepub fn conflicts_with(self, cap_id: CapabilityId) -> Self
pub fn conflicts_with(self, cap_id: CapabilityId) -> Self
Add a conflict (builder pattern)
Sourcepub fn conflicts_with_all(
self,
cap_ids: impl IntoIterator<Item = CapabilityId>,
) -> Self
pub fn conflicts_with_all( self, cap_ids: impl IntoIterator<Item = CapabilityId>, ) -> Self
Add multiple conflicts
Sourcepub fn codimension(&self) -> usize
pub fn codimension(&self) -> usize
Codimension of this capability’s Schubert class
§Contract
ensures: result == self.schubert_class.codimension()Sourcepub fn has_dependencies(&self) -> bool
pub fn has_dependencies(&self) -> bool
Check if this capability has any dependencies
Sourcepub fn has_conflicts(&self) -> bool
pub fn has_conflicts(&self) -> bool
Check if this capability has any conflicts
Trait Implementations§
Source§impl Clone for Capability
impl Clone for Capability
Source§fn clone(&self) -> Capability
fn clone(&self) -> Capability
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more