Expand description
Ctx typed service registry, Plugin, activation, Disposer
(DESIGN §6.1, ADR-004).
Mapping from Cordis (ADR-004):
- Stable service keys: a service is registered by trait-object type
(
ctx.provide::<dyn ModelProvider>(impl)/ctx.resolve::<dyn ModelProvider>); one implementation per key — a second registration is a named error. - Reversible registration:
trait Plugin { fn apply(self, ctx: &mut Ctx) -> Result<Disposer, PluginError> }— everythingapplyinstalls (services, event handlers) is unwound by the returnedDisposer. - inject → topology: plugins declare dependencies by name;
PluginSet::activateruns them in a deterministic topological order (ties broken by declaration order); cycles are a named error. - Disposers unwind in reverse order exactly once, on explicit
dispose()or on drop.
Static (compile-time) plugins only — crate::kian_plugins! assembles a
PluginSet; dynamic loading (dylib/wasm) is deferred.
Structs§
- Ctx
- Typed service registry (Cordis
ctxcontainer). Service keys are stable: the key is theTypeIdof the trait-object type (dyn Greeter) or of a concrete type; values areArc<dyn Any + Send + Sync>wrappers aroundArc<S>. - Disposer
- Reversible side effect (Cordis disposer). Callbacks run in reverse
insertion order, exactly once — on explicit
Disposer::disposeor on drop. Registration and disposal are paired. - Plugin
Set - The compile-time plugin set assembled by
crate::kian_plugins!. Activation order is derived from declared dependencies, not listing order.
Enums§
- Plugin
Error - Named errors for the plugin subsystem (acceptance criteria).
Traits§
- Plugin
- A statically-registered capability unit (ADR-004).
applyinstalls services and event handlers intoCtxand returns theDisposerthat unwinds them; dependencies are declared by plugin name and resolved by topological activation (the static equivalent of Cordisinject). - Service
- Marker bound for services stored in
Ctx: any'staticSend + Synctype (trait object or concrete) can occupy a service key.