Skip to main content

RoutingEngine

Struct RoutingEngine 

Source
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

Source

pub fn new() -> Self

Source

pub async fn replace_all(&self, mappings: Vec<Mapping>)

Replace all mappings with the provided set. Used on config_full push.

Source

pub async fn upsert_mapping(&self, mapping: Mapping)

Insert or replace one mapping, keyed by mapping_id. Used on config_patch upsert.

Source

pub async fn remove_mapping(&self, id: &Uuid)

Remove any mapping with the given mapping_id. Used on config_patch delete.

Source

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.

Source

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.

Source

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).

Source

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.

Source

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.

Source

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.

Trait Implementations§

Source§

impl Default for RoutingEngine

Source§

fn default() -> RoutingEngine

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more