English
requires
Module::requires — the names of the modules this module does not work without: whose points it extends, whose services it takes, on whose crates its crate depends.
What requires gives
- Presence. A binary with the module but without what it requires does not build (the const check) and does not start (
Modules::new). - Order. The kernel orders modules so that each comes after the ones it requires (Module order). A module's unit is built after the units of the required ones and sees their services; it is closed before them.
- The right to extend. An
Extension/Blockinto another module's point is allowed only if its owner is inrequires.
When a module must require another
- It extends its point:
transport-ws→transport,transport-grpc→transport;rule-process→router(conditions into theconditionspoint). - Its crate depends on the module's crate (a normal dependency in
[dependencies]):clients→wireguard, the only crate dependency between modules thattests/layers.pyallows (Layers). An optional dependency counts only when its module is built. - It takes another module's service — by a type of the contract or of a shared crate (
ours_api::cache::of(services),ours_tls_options::Tls::of), so item 2 is not needed.
The converse is not mandatory: a module may require another without depending on its crate (using a point by name).
How it is checked
| Check | Where | When |
|---|---|---|
requires_are_listed(LIST) in const _: () = assert!(...) | app/ours/src/modules.rs | compiling the binary: every requires is in LIST with the given set of features |
Modules::new | crates/kernel/src/modules.rs | start, and the binary's the_list_is_sound test (app/ours/src/modules.rs): presence, a cycle, extending without requiring |
a_module_requires_the_modules_its_crate_depends_on | app/ours/src/modules.rs | cargo test: a crate dependency ⇒ requires (by the uses.rs table from build.rs) |
tests/features.py | — | every feature and default minus one compile, so the const check passes in every combination |
The const check compares strings byte by byte (const fn same), because == for &str is not available in const context.