Skip to content

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/Block into another module's point is allowed only if its owner is in requires.

When a module must require another ​

  1. It extends its point: transport-ws → transport, transport-grpc → transport; rule-process → router (conditions into the conditions point).
  2. Its crate depends on the module's crate (a normal dependency in [dependencies]): clients → wireguard, the only crate dependency between modules that tests/layers.py allows (Layers). An optional dependency counts only when its module is built.
  3. 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 ​

CheckWhereWhen
requires_are_listed(LIST) in const _: () = assert!(...)app/ours/src/modules.rscompiling the binary: every requires is in LIST with the given set of features
Modules::newcrates/kernel/src/modules.rsstart, 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_onapp/ours/src/modules.rscargo 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.

GPL-3.0-or-later