ndn_engine/enricher.rs
1use ndn_strategy::FibEntry;
2use ndn_transport::AnyMap;
3
4/// Populates cross-layer data in the strategy context extensions.
5///
6/// Implementations pull from whatever data source they own (RadioTable,
7/// FlowTable, GPS receiver, battery monitor, ...) and insert a DTO into
8/// the `AnyMap`. `StrategyStage` holds a `Vec<Arc<dyn ContextEnricher>>`
9/// and calls each one before every strategy invocation.
10///
11/// # Adding a new data source
12///
13/// 1. Define a DTO struct (e.g. `LocationSnapshot`) in `ndn-strategy::cross_layer`.
14/// 2. Implement `ContextEnricher` — read your data source, build the DTO,
15/// call `extensions.insert(dto)`.
16/// 3. Register via `EngineBuilder::context_enricher(Arc::new(YourEnricher { ... }))`.
17///
18/// No changes to `StrategyContext`, `StrategyStage`, or existing enrichers are needed.
19pub trait ContextEnricher: Send + Sync + 'static {
20 /// Human-readable name (for logging / debug).
21 fn name(&self) -> &str;
22
23 /// Insert zero or more typed values into `extensions`.
24 fn enrich(&self, fib_entry: Option<&FibEntry>, extensions: &mut AnyMap);
25}