pub struct MeshRouter<A: Aggregator = NoOpAggregator> { /* private fields */ }Expand description
Unified mesh router combining routing, aggregation, and transport
MeshRouter provides a high-level API for routing data through the mesh hierarchy while handling deduplication and aggregation automatically.
The type parameter A determines which aggregation strategy is used.
Use NoOpAggregator (the default) when aggregation is not needed.
Implementations§
Source§impl<A: Aggregator> MeshRouter<A>
impl<A: Aggregator> MeshRouter<A>
Sourcepub fn with_aggregator(config: MeshRouterConfig, aggregator: A) -> Self
pub fn with_aggregator(config: MeshRouterConfig, aggregator: A) -> Self
Create a new mesh router with a specific aggregator
Sourcepub fn route(&self, packet: &DataPacket, state: &TopologyState) -> RouteResult
pub fn route(&self, packet: &DataPacket, state: &TopologyState) -> RouteResult
Route an incoming packet and determine what to do with it
This is the main entry point for processing received packets. It handles deduplication, routing decisions, and aggregation checks.
§Arguments
packet- The incoming data packetstate- Current topology state
§Returns
RouteResult containing the routing decision and forwarding targets
Sourcepub fn add_for_aggregation(
&self,
packet: DataPacket,
squad_id: &str,
) -> Option<DataPacket>
pub fn add_for_aggregation( &self, packet: DataPacket, squad_id: &str, ) -> Option<DataPacket>
Add a telemetry packet to the aggregation buffer
If aggregation threshold is reached, returns aggregated packet. Otherwise returns None.
Sourcepub fn pending_aggregation_count(&self) -> usize
pub fn pending_aggregation_count(&self) -> usize
Get the number of packets pending aggregation
Sourcepub fn flush_aggregation(&self, squad_id: &str) -> Option<DataPacket>
pub fn flush_aggregation(&self, squad_id: &str) -> Option<DataPacket>
Force aggregation of pending packets (even if below threshold)
Sourcepub fn router(&self) -> &SelectiveRouter
pub fn router(&self) -> &SelectiveRouter
Get the underlying router for advanced operations
Sourcepub fn aggregator(&self) -> &A
pub fn aggregator(&self) -> &A
Get the underlying aggregator for advanced operations
Sourcepub fn dedup_cache_size(&self) -> usize
pub fn dedup_cache_size(&self) -> usize
Get deduplication cache size
Sourcepub fn clear_dedup_cache(&self)
pub fn clear_dedup_cache(&self)
Clear deduplication cache