Skip to main content

Module engine

Module engine 

Source
Expand description

Lock-free DI engine + macro registration descriptors.

Two-phase lifecycle:

  1. Boot. DiContainerBuilder collects ProviderDescriptors emitted by #[Injectable] / #[Module]. It topologically sorts them by TypeId dependency edges, detects cycles deterministically, then invokes each provider’s build function in dependency order. The build function receives a Resolver view of already-constructed singletons.

  2. Run. The container is Box::leak-ed to &'static FrozenDiContainer. Every subsequent read is a single HashMap::get + downcast, both inlined. Zero locks, zero allocations on the request path.

Structs§

DiContainerBuilder
Mutable builder used only during boot.
FrozenDiContainer
Immutable, lock-free DI container. Reads are O(1) and inlined.
ModuleDescriptor
Emitted by #[Module]. Owns its providers, the controllers it exposes, and the imports it pulls in. Used to walk the module DAG at boot.
ParamSpec
ProviderDescriptor
One row in the dependency graph.
Resolver
Build-time resolver passed to each provider’s build fn. Returns the already-constructed dependency by TypeId. Panics if a dependency hasn’t been built yet — topological order guarantees this can’t happen for a well-formed graph.
RouteDescriptor
RouteSpec

Enums§

HttpMethod
ParamLoc

Traits§

Module
Implemented by every #[Module]-annotated struct so App::launch::<RootMod> can find the entry point without a runtime registry lookup.

Type Aliases§

AnyProvider