pub struct PidRouter { /* private fields */ }Expand description
A static mapping from Prüfidentifikator (PID) values to workflow names.
Register all PIDs your platform handles before starting the engine. At
runtime, call route to look up the workflow name for an inbound PID.
The workflow name matches WorkflowId::name — use it to select the
correct Workflow implementation in your message dispatcher.
§Mutability contract
PidRouter exposes a &mut self API for registrations (register). In
the engine this mutability is exercised only during
EngineBuilder::build — after that the router is owned by
EngineContext and only shared references are available at runtime.
There is no way to mutate the router from an async dispatch handler.
Duplicate registrations silently replace the previous mapping; the last
call wins. Use cargo xtask validate-pruefids to detect PID conflicts
between modules before they reach production.
§Building a complete router
In your main or integration module, register every PID that the platform
must handle. PIDs not registered will return None from route, causing
the dispatcher to dead-letter the message cleanly.
use mako_engine::pid_router::PidRouter;
fn build_router() -> PidRouter {
let mut r = PidRouter::new();
// GPKE Lieferantenwechsel (BK6-22-024) — UTILMD
r.register(55001, "GpkeSupplierChange");
r.register(55002, "GpkeSupplierChange");
r.register(55003, "GpkeSupplierChange");
r.register(55004, "GpkeSupplierChange");
r
}Implementations§
Source§impl PidRouter
impl PidRouter
Sourcepub fn register(&mut self, pid: u32, workflow_name: impl Into<Box<str>>)
pub fn register(&mut self, pid: u32, workflow_name: impl Into<Box<str>>)
Register pid as routing to workflow_name.
If pid was already registered, the previous mapping is silently
replaced. Call this only at build time (via EngineModule::register_pids);
the method is &mut self to prevent accidental runtime mutation once the
router is sealed inside EngineContext.
Accepts any string — &'static str, String, or Box<str>.
For conflict-detected registration (preferred in multi-module builds),
use register_with_module instead.
Sourcepub fn register_with_module(
&mut self,
pid: u32,
workflow_name: impl Into<Box<str>>,
module: &str,
)
pub fn register_with_module( &mut self, pid: u32, workflow_name: impl Into<Box<str>>, module: &str, )
Register pid → workflow_name with module-attribution conflict detection.
§Panics
Panics at build time (before the engine starts) if pid is already
registered to a different workflow name by a different module. Two
modules registering the same PID to the same workflow are silently
accepted (idempotent).
Use DeploymentRoles to prevent two modules from registering the same
PID when only one role is active:
// Both GPKE (NB role) and WiM (nMSB role) register 19001 → different workflows.
// Set explicit roles so only one module's conditional block fires:
use mako_engine::marktrolle::{DeploymentRoles, Marktrolle};
let roles = DeploymentRoles::from_roles([Marktrolle::Nb]);
// Now only GPKE registers 19001 → "gpke-konfiguration".Sourcepub fn register_with_sparte(
&mut self,
pid: u32,
sparte: Sparte,
workflow_name: impl Into<Box<str>>,
)
pub fn register_with_sparte( &mut self, pid: u32, sparte: Sparte, workflow_name: impl Into<Box<str>>, )
Register pid → workflow_name for a specific commodity (Sparte).
Use this for PIDs that map to different workflows depending on whether
the message concerns electricity (Strom) or gas (Gas). At runtime call
route_with_sparte to prefer the commodity-specific entry over the
unambiguous fallback registered via register.
§INSRPT shared PIDs (23001/23003/23004/23008)
These PIDs appear in both WiM Strom (5 WT) and WiM Gas (10 WT) AHBs:
// In WimModule (Strom):
router.register_with_sparte(23001, Sparte::Strom, "wim-insrpt");
// In WimGasModule (Gas):
router.register_with_sparte(23001, Sparte::Gas, "wim-gas-insrpt");Sourcepub fn route_with_sparte(&self, pid: u32, sparte: Sparte) -> Option<&str>
pub fn route_with_sparte(&self, pid: u32, sparte: Sparte) -> Option<&str>
Look up the workflow name for pid, preferring the commodity-qualified
entry for sparte over the unambiguous fallback.
Resolution order:
commodity_table[(pid, sparte)]— registered viaregister_with_spartetable[pid]— registered viaregister(unambiguous fallback)
Returns None when neither table has an entry for pid.
§INSRPT routing example
use mako_engine::pid_router::PidRouter;
use mako_engine::types::Sparte;
let mut r = PidRouter::new();
r.register(23001, "wim-insrpt"); // Strom fallback
r.register_with_sparte(23001, Sparte::Strom, "wim-insrpt");
r.register_with_sparte(23001, Sparte::Gas, "wim-gas-insrpt");
assert_eq!(r.route_with_sparte(23001, Sparte::Strom), Some("wim-insrpt"));
assert_eq!(r.route_with_sparte(23001, Sparte::Gas), Some("wim-gas-insrpt"));
assert_eq!(r.route(23001), Some("wim-insrpt"));Sourcepub fn route(&self, pid: u32) -> Option<&str>
pub fn route(&self, pid: u32) -> Option<&str>
Look up the workflow name for pid.
Returns None when pid has not been registered. The caller should
dead-letter the message and return an appropriate error to the sender
rather than panicking.
Sourcepub fn registered_pids(&self) -> impl Iterator<Item = u32> + '_
pub fn registered_pids(&self) -> impl Iterator<Item = u32> + '_
Return an iterator over all registered PID values.
Useful for validation (e.g. comparing against PIDs declared in AHB profile JSON files to detect missing workflow implementations).