Module lane

Module lane 

Source
Expand description

§Lane Abstraction

The unified base trait for all lane types in the KhoraEngine.

A Lane is a reusable, swappable processing strategy within an agent. Agents compose and select lanes based on resource budgets (GORNA protocol) and quality targets. Each lane encapsulates a specific algorithmic approach to a domain task (rendering, physics, audio, asset loading, etc.).

§Architecture

The Lane system follows a two-level trait hierarchy:

  1. Lane (this trait) — Common interface shared by ALL lane types. Provides identity, classification, and cost estimation.

  2. Domain-specific traits — Extend Lane with domain-specific execution methods. Examples:

    • RenderLane: Lane — GPU rendering strategies
    • ShadowLane: Lane — Shadow map generation strategies
    • PhysicsLane: Lane — Physics simulation strategies
    • AudioMixingLane: Lane — Audio mixing strategies
    • AssetLoaderLane<A>: Lane — Asset loading strategies
    • SerializationStrategy: Lane — Scene serialization strategies

§Usage

use khora_core::lane::{Lane, LaneKind, LaneError, LaneContext};

struct MyCustomLane { initialized: std::sync::atomic::AtomicBool }

impl Lane for MyCustomLane {
    fn strategy_name(&self) -> &'static str { "MyCustom" }
    fn lane_kind(&self) -> LaneKind { LaneKind::Render }

    fn on_initialize(&self, _ctx: &mut LaneContext) -> Result<(), LaneError> {
        self.initialized.store(true, std::sync::atomic::Ordering::Relaxed);
        Ok(())
    }

    fn execute(&self, _ctx: &mut LaneContext) -> Result<(), LaneError> {
        // Domain-specific work here
        Ok(())
    }

    fn as_any(&self) -> &dyn std::any::Any { self }
    fn as_any_mut(&mut self) -> &mut dyn std::any::Any { self }
}

Re-exports§

pub use context_keys::*;

Modules§

context_keys
Domain-agnostic context key types for LaneContext.

Structs§

LaneContext
A type-erased, extensible context for passing data to lanes.
LaneRegistry
A registry that stores Lane trait objects for agent use.
Ref
Wraps a shared borrow for storage in LaneContext.
Slot
Wraps a mutable borrow for storage in LaneContext.

Enums§

LaneError
Error type for lane operations.
LaneKind
Classification of lane types, used for routing and filtering.

Traits§

Lane
Base trait for ALL lane types in the KhoraEngine.