Skip to main content

CapabilityComposition

Struct CapabilityComposition 

Source
pub struct CapabilityComposition<'a, C: Capability> { /* private fields */ }
Expand description

A caller-owned, single-capability composition snapshot.

This prototype stores declarations only; it does not construct modules or keep global state. Edits return a new snapshot so callers can validate the resulting graph before adopting it.

Implementations§

Source§

impl<'a, C: Capability> CapabilityComposition<'a, C>

Source

pub fn new( provisions: Vec<Provision<'a, C>>, requirements: Vec<CapabilityRequirement<C>>, ) -> Self

Creates a composition snapshot from providers and consumer requirements.

Source

pub fn without_module(&self, module: ModuleId) -> Self

Removes a module’s declarations and revalidates the remaining graph.

Requirements owned by other modules remain, even when the removed module was their selected provider; validation then reports the broken edge.

Source

pub fn requirements(&self) -> &[CapabilityRequirement<C>]

Returns the active consumer requirements in this snapshot.

Source

pub fn replace_provider( &self, replaced: ModuleId, replacement: Provision<'a, C>, ) -> Option<Self>

Replaces one provider for this capability while retaining module requirements and redirecting explicit selections to the replacement. Returns None when replaced does not currently provide this capability.

Source

pub fn resolve_requirement( &self, requirement: CapabilityRequirement<C>, ) -> Result<&'a C::Value, CompositionError>

Resolves one declared requirement against this snapshot.

Source

pub fn validate(&self) -> Result<(), CompositionError>

Revalidates every consumer requirement in this snapshot.

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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.