pub trait PackFactory:
Send
+ Sync
+ 'static {
// Required methods
fn name(&self) -> &'static str;
fn create(&self, runtime: KhiveRuntime) -> Box<dyn PackRuntime>;
// Provided methods
fn requires(&self) -> &'static [&'static str] { ... }
fn create_install(&self, runtime: KhiveRuntime) -> PackInstall { ... }
fn create_resolver(
&self,
_runtime: KhiveRuntime,
) -> Option<Box<dyn PackByIdResolver>> { ... }
}Expand description
Factory for creating pack instances registered via inventory at link time.
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§
Sourcefn create(&self, runtime: KhiveRuntime) -> Box<dyn PackRuntime>
fn create(&self, runtime: KhiveRuntime) -> Box<dyn PackRuntime>
Create a new pack instance for the given runtime.
Provided Methods§
Sourcefn requires(&self) -> &'static [&'static str]
fn requires(&self) -> &'static [&'static str]
Names of packs that must be loaded before this one.
Defaults to empty so pack crates that have no dependencies compile
without changes. PackRegistry::register_packs validates that every
name listed here is present in the caller’s explicit pack list — absent
dependencies are a boot error, not silently auto-added.
Sourcefn create_install(&self, runtime: KhiveRuntime) -> PackInstall
fn create_install(&self, runtime: KhiveRuntime) -> PackInstall
Build the full installation bundle for this pack: runtime, optional resolver, optional dispatch hook.
Defaults to composing create and create_resolver with no dispatch
hook, so existing factories compile unchanged. Packs whose dispatch
hook must observe the same instance as the runtime (e.g. brain)
override this method instead of create, since the default would
otherwise require two independent instances to share state.
Sourcefn create_resolver(
&self,
_runtime: KhiveRuntime,
) -> Option<Box<dyn PackByIdResolver>>
fn create_resolver( &self, _runtime: KhiveRuntime, ) -> Option<Box<dyn PackByIdResolver>>
Optionally create a PackByIdResolver for this pack.
Packs that own private SQL tables implement this to hook into
get(id) and delete(id). Defaults to None so existing packs
compile without changes.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".