pub struct RoutingEngine { /* private fields */ }Expand description
Thread-safe registry of currently-active mappings, keyed by
(device_type, device_id) for O(1) lookup per input event.
Implementations§
Source§impl RoutingEngine
impl RoutingEngine
pub fn new() -> Self
Sourcepub async fn replace_all(&self, mappings: Vec<Mapping>)
pub async fn replace_all(&self, mappings: Vec<Mapping>)
Replace all mappings with the provided set. Used on config_full push.
Sourcepub async fn upsert_mapping(&self, mapping: Mapping)
pub async fn upsert_mapping(&self, mapping: Mapping)
Insert or replace one mapping, keyed by mapping_id. Used on
config_patch upsert.
Sourcepub async fn remove_mapping(&self, id: &Uuid)
pub async fn remove_mapping(&self, id: &Uuid)
Remove any mapping with the given mapping_id. Used on
config_patch delete.
Sourcepub async fn snapshot(&self) -> Vec<Mapping>
pub async fn snapshot(&self) -> Vec<Mapping>
Snapshot every mapping currently held, grouped or not. Used to persist the local cache after an incremental patch.
Sourcepub async fn feedback_rules_for_target(
&self,
service_type: &str,
target: &str,
) -> Vec<FeedbackRule>
pub async fn feedback_rules_for_target( &self, service_type: &str, target: &str, ) -> Vec<FeedbackRule>
Feedback rules attached to whichever mapping covers the given
(service_type, target) — either as its primary target or as a
listed candidate (including candidates that override the mapping’s
service_type). Returns an empty vec when no mapping covers the
target, letting the caller fall back to hardcoded defaults.
Feedback is stored at the mapping level (all candidates share one
rule set), so a candidate match still returns the mapping’s
feedback.
Sourcepub async fn feedback_rules_for_device_target(
&self,
device_type: &str,
device_id: &str,
service_type: &str,
target: &str,
) -> Option<Vec<FeedbackRule>>
pub async fn feedback_rules_for_device_target( &self, device_type: &str, device_id: &str, service_type: &str, target: &str, ) -> Option<Vec<FeedbackRule>>
Same as feedback_rules_for_target but scoped to one (device_type, device_id) bucket. Use this from per-device feedback pumps so a
Nuimo only reacts when the state change belongs to a mapping it
owns — otherwise a second Nuimo mapped elsewhere would flash glyphs
for unrelated service activity.
Returns None when no mapping on this device covers
(service_type, target) — the caller should skip. Returns
Some(vec) when a mapping exists; the vec may be empty, which
signals “mapping exists but user configured no rules — fall back
to hardcoded defaults” (preserves single-device behavior).
Sourcepub async fn feedback_targets_for(
&self,
service_type: &str,
target: &str,
) -> Vec<(String, String, Vec<FeedbackRule>)>
pub async fn feedback_targets_for( &self, service_type: &str, target: &str, ) -> Vec<(String, String, Vec<FeedbackRule>)>
Find every device whose mapping owns (service_type, target) and
return its (device_type, device_id, feedback_rules). Used by the
iOS feedback pump, which fans a single state update out to every
LED that should display it — typically 1 device, but two Nuimos
paired to the same iPad both deserve feedback.
Sourcepub async fn route(
&self,
device_type: &str,
device_id: &str,
input: &InputPrimitive,
) -> Vec<RoutedIntent>
pub async fn route( &self, device_type: &str, device_id: &str, input: &InputPrimitive, ) -> Vec<RoutedIntent>
Apply the given input primitive from a specific device, returning every intent it produces across all matching mappings.
Sourcepub async fn route_with_mode(
&self,
device_type: &str,
device_id: &str,
input: &InputPrimitive,
) -> RouteOutcome
pub async fn route_with_mode( &self, device_type: &str, device_id: &str, input: &InputPrimitive, ) -> RouteOutcome
Same dispatch as route, but also implements the target-selection
state machine (Mapping.target_switch_on + target_candidates).
Callers that want on-device target switching should use this
instead of route.