Skip to main content

MeshRouter

Struct MeshRouter 

Source
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 MeshRouter<NoOpAggregator>

Source

pub fn new(config: MeshRouterConfig) -> Self

Create a new mesh router with no aggregation

Source

pub fn with_node_id(node_id: impl Into<String>) -> Self

Create with default configuration and node ID (no aggregation)

Source§

impl<A: Aggregator> MeshRouter<A>

Source

pub fn with_aggregator(config: MeshRouterConfig, aggregator: A) -> Self

Create a new mesh router with a specific aggregator

Source

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 packet
  • state - Current topology state
§Returns

RouteResult containing the routing decision and forwarding targets

Source

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.

Source

pub fn pending_aggregation_count(&self) -> usize

Get the number of packets pending aggregation

Source

pub fn flush_aggregation(&self, squad_id: &str) -> Option<DataPacket>

Force aggregation of pending packets (even if below threshold)

Source

pub fn router(&self) -> &SelectiveRouter

Get the underlying router for advanced operations

Source

pub fn aggregator(&self) -> &A

Get the underlying aggregator for advanced operations

Source

pub fn node_id(&self) -> &str

Get the node ID this router is configured for

Source

pub fn dedup_cache_size(&self) -> usize

Get deduplication cache size

Source

pub fn clear_dedup_cache(&self)

Clear deduplication cache

Auto Trait Implementations§

§

impl<A> Freeze for MeshRouter<A>
where A: Freeze,

§

impl<A> RefUnwindSafe for MeshRouter<A>
where A: RefUnwindSafe,

§

impl<A> Send for MeshRouter<A>

§

impl<A> Sync for MeshRouter<A>

§

impl<A> Unpin for MeshRouter<A>
where A: Unpin,

§

impl<A> UnsafeUnpin for MeshRouter<A>
where A: UnsafeUnpin,

§

impl<A> UnwindSafe for MeshRouter<A>
where A: UnwindSafe,

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