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:
-
Lane(this trait) — Common interface shared by ALL lane types. Provides identity, classification, and cost estimation. -
Domain-specific traits — Extend
Lanewith domain-specific execution methods. Examples:RenderLane: Lane— GPU rendering strategiesShadowLane: Lane— Shadow map generation strategiesPhysicsLane: Lane— Physics simulation strategiesAudioMixingLane: Lane— Audio mixing strategiesAssetLoaderLane<A>: Lane— Asset loading strategiesSerializationStrategy: 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§
- Lane
Context - A type-erased, extensible context for passing data to lanes.
- Lane
Registry - A registry that stores
Lanetrait objects for agent use. - Ref
- Wraps a shared borrow for storage in
LaneContext. - Slot
- Wraps a mutable borrow for storage in
LaneContext.
Enums§
- Lane
Error - Error type for lane operations.
- Lane
Kind - Classification of lane types, used for routing and filtering.
Traits§
- Lane
- Base trait for ALL lane types in the KhoraEngine.