Skip to main content

PackFactory

Trait PackFactory 

Source
pub trait PackFactory:
    Send
    + Sync
    + 'static {
    // Required methods
    fn name(&self) -> &'static str;
    fn create(&self, runtime: KhiveRuntime) -> Box<dyn PackRuntime>;

    // Provided method
    fn requires(&self) -> &'static [&'static str] { ... }
}
Expand description

Factory for creating pack instances registered via inventory at link time (ADR-063). Each pack crate submits a &'static dyn PackFactory wrapped in a PackRegistration; the binary’s linker collects them all into a single slice iterable at runtime.

Implementors must be Send + Sync + 'static because the registry is built once and shared across async tasks.

Required Methods§

Source

fn name(&self) -> &'static str

Canonical lowercase name for this pack (e.g. "kg", "gtd").

Source

fn create(&self, runtime: KhiveRuntime) -> Box<dyn PackRuntime>

Create a new pack instance for the given runtime.

Provided Methods§

Source

fn requires(&self) -> &'static [&'static str]

Names of packs that must be loaded before this one (ADR-037).

Defaults to empty so pack crates that have no dependencies compile without changes. PackRegistry::register_packs uses this to compute the transitive closure of required packs before registering anything.

Implementors§