uor-foundation 0.2.0

UOR Foundation — typed Rust traits for the complete ontology. Import and implement.
Documentation
// @generated by uor-crate from uor-ontology — do not edit manually

//! `linear/` namespace — Linear discipline on site consumption. Formalizes that each site in a complete resolution path is targeted by exactly one effect..
//!
//! Space: Kernel

use crate::Primitives;

/// A site index annotated with a linearity constraint: must be pinned exactly once in any complete resolution path.
pub trait LinearSite<P: Primitives>: crate::bridge::partition::SiteIndex<P> {}

/// A PinningEffect that consumes its target LinearSite. After application, the site is no longer available for pinning by any subsequent effect.
pub trait LinearEffect<P: Primitives>: crate::kernel::effect::PinningEffect<P> {
    /// Associated type for `LinearSite`.
    type LinearSite: LinearSite<P>;
    /// The single site consumed by this effect.
    fn linear_target(&self) -> &Self::LinearSite;
}

/// A computation trace where every site in the budget is targeted by exactly one LinearEffect.
pub trait LinearTrace<P: Primitives>: crate::bridge::trace::ComputationTrace<P> {}

/// The multiset of LinearSites available at a given point in resolution. Starts as the full site budget; each LinearEffect removes exactly one element.
pub trait LinearBudget<P: Primitives> {
    /// Associated type for `LinearSite`.
    type LinearSite: LinearSite<P>;
    /// The sites remaining in the budget.
    fn budget_sites(&self) -> &[Self::LinearSite];
    /// Associated type for `Context`.
    type Context: crate::user::state::Context<P>;
    /// The context associated with this budget state.
    fn budget_context(&self) -> &Self::Context;
    /// Number of unconsumed sites. Equals freeRank on the associated context.
    fn remaining_count(&self) -> P::NonNegativeInteger;
}

/// A binding between a state:ContextLease and a subset of LinearSites. Formalizes what resources a lease claims.
pub trait LeaseAllocation<P: Primitives> {
    /// Associated type for `LinearSite`.
    type LinearSite: LinearSite<P>;
    /// The sites claimed by this lease.
    fn lease_target(&self) -> &[Self::LinearSite];
    /// Associated type for `ContextLease`.
    type ContextLease: crate::user::state::ContextLease<P>;
    /// The ContextLease individual that owns this allocation.
    fn lease_source(&self) -> &Self::ContextLease;
    /// Number of sites claimed by this lease.
    fn lease_cardinality(&self) -> P::PositiveInteger;
}

/// A site that may be pinned at most once (but need not be pinned). Relaxation of LinearSite for incomplete resolution paths.
pub trait AffineSite<P: Primitives>: crate::bridge::partition::SiteIndex<P> {}