Skip to main content

Namespace

Struct Namespace 

Source
pub struct Namespace {
    pub grassmannian: (usize, usize),
    pub position: SchubertClass,
    pub capabilities: Vec<Capability>,
    pub name: String,
}
Expand description

A namespace: a point in a Grassmannian with associated capabilities

In ShaperOS, namespaces represent isolated execution contexts. Their position in the Grassmannian encodes their “geometric location” while their capabilities determine what operations they can perform.

§Contracts

  • All capabilities must be compatible with the namespace’s Grassmannian
  • Capabilities must satisfy dependency ordering
  • No two conflicting capabilities can coexist

Fields§

§grassmannian: (usize, usize)

The Grassmannian this namespace lives in: Gr(k, n)

§position: SchubertClass

Schubert cell containing this namespace (its “position”)

§capabilities: Vec<Capability>

Capabilities granted to this namespace

§name: String

Human-readable name

Implementations§

Source§

impl Namespace

Source

pub fn new(name: impl Into<String>, position: SchubertClass) -> Self

Create a new namespace at a given Schubert position

Source

pub fn full( name: impl Into<String>, k: usize, n: usize, ) -> EnumerativeResult<Self>

Create a namespace with full access (identity Schubert class)

§Contract
requires: k < n
ensures: result.position.partition.is_empty()
ensures: result.grassmannian == (k, n)
Source

pub fn grant(&mut self, capability: Capability) -> Result<(), NamespaceError>

Grant a capability to this namespace

§Contract
requires: forall dep in capability.requires. self.has_capability(dep)
requires: forall conf in capability.conflicts. !self.has_capability(conf)
requires: forall existing in self.capabilities. !existing.conflicts.contains(capability.id)
ensures: self.has_capability(capability.id)
§Errors

Returns NamespaceError::Conflict if the capability conflicts with an existing one. Returns NamespaceError::MissingDependency if a required capability is missing.

Source

pub fn grant_all( &mut self, capabilities: Vec<Capability>, ) -> Result<(), NamespaceError>

Try to grant multiple capabilities in dependency order

This is a convenience method that attempts to grant capabilities in the order that satisfies dependencies.

Source

pub fn revoke(&mut self, id: &CapabilityId) -> bool

Revoke a capability from this namespace

§Contract
requires: no other capability depends on this one
ensures: !self.has_capability(id)

Returns true if the capability was revoked, false if it couldn’t be (either not present or has dependents).

Source

pub fn has_capability(&self, id: &CapabilityId) -> bool

Check if this namespace has a specific capability

Source

pub fn capability_ids(&self) -> Vec<CapabilityId>

Get all capability IDs

Source

pub fn capability_count(&self) -> usize

Get the number of capabilities

Source

pub fn count_configurations(&self) -> IntersectionResult

Count valid configurations satisfying all capability constraints

This computes the intersection number of the position Schubert class with all capability Schubert classes.

§Contract
ensures:
  - total_codim > dim(Gr) => Empty
  - total_codim == dim(Gr) => Finite(n) where n >= 0
  - total_codim < dim(Gr) => PositiveDimensional
Source

pub fn total_codimension(&self) -> usize

Total codimension of position plus all capabilities

Source

pub fn would_overdetermine(&self, capability: &Capability) -> bool

Check if adding a capability would make the system overdetermined

Trait Implementations§

Source§

impl Clone for Namespace

Source§

fn clone(&self) -> Namespace

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Namespace

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.