uor-foundation 0.1.3

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 fiber consumption. Formalizes that each fiber in a complete resolution path is targeted by exactly one effect..
//!
//! Space: Kernel

use crate::Primitives;

/// A fiber coordinate annotated with a linearity constraint: must be pinned exactly once in any complete resolution path.
pub trait LinearFiber<P: Primitives>: crate::bridge::partition::FiberCoordinate<P> {}

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

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

/// The multiset of LinearFibers available at a given point in resolution. Starts as the full fiber budget; each LinearEffect removes exactly one element.
pub trait LinearBudget<P: Primitives> {
    /// Associated type for `LinearFiber`.
    type LinearFiber: LinearFiber<P>;
    /// The fibers remaining in the budget.
    fn budget_fibers(&self) -> &[Self::LinearFiber];
    /// 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 fibers. Equals freeCount on the associated context.
    fn remaining_count(&self) -> P::NonNegativeInteger;
}

/// A binding between a state:ContextLease and a subset of LinearFibers. Formalizes what resources a lease claims.
pub trait LeaseAllocation<P: Primitives> {
    /// Associated type for `LinearFiber`.
    type LinearFiber: LinearFiber<P>;
    /// The fibers claimed by this lease.
    fn lease_target(&self) -> &[Self::LinearFiber];
    /// 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 fibers claimed by this lease.
    fn lease_cardinality(&self) -> P::PositiveInteger;
}

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