Skip to main content

RouterTable

Struct RouterTable 

Source
pub struct RouterTable { /* private fields */ }
Expand description

BACnet routing table.

Maps network numbers to the port through which they can be reached.

Implementations§

Source§

impl RouterTable

Source

pub fn new() -> Self

Create an empty routing table.

Source

pub fn add_direct(&mut self, network: u16, port_index: usize)

Add a directly-connected network on the given port. Network 0 and 0xFFFF are reserved and will be silently ignored.

Source

pub fn add_learned( &mut self, network: u16, port_index: usize, next_hop_mac: MacAddr, )

Add a learned route (network reachable via a next-hop router on the given port). Network 0 and 0xFFFF are reserved and will be silently ignored. Does not overwrite direct routes.

Source

pub fn add_learned_with_flap_detection( &mut self, network: u16, port_index: usize, next_hop_mac: MacAddr, ) -> bool

Add a learned route, always accepting (spec 6.6.3.2: last I-Am-Router wins). Detects rapid port changes for operator visibility but never suppresses updates.

Returns true if the route was inserted/updated.

Source

pub fn mark_busy(&mut self, network: u16, deadline: Instant)

Mark a network as busy with a deadline for auto-clear (spec 6.6.3.6).

Source

pub fn mark_available(&mut self, network: u16)

Mark a network as available, clearing any busy state (spec 6.6.3.7).

Source

pub fn mark_unreachable(&mut self, network: u16)

Mark a network as permanently unreachable (spec 6.6.3.5, reject reason 1). Keeps the entry in the table (unlike remove).

Source

pub fn clear_expired_busy(&mut self)

Clear busy state for entries whose busy_until deadline has elapsed.

Source

pub fn effective_reachability(&self, network: u16) -> Option<ReachabilityStatus>

Get effective reachability, checking busy_until inline for immediate accuracy. This avoids up to 90s worst-case from the 60s aging sweep granularity.

Source

pub fn lookup(&self, network: u16) -> Option<&RouteEntry>

Look up the route for a network number.

Source

pub fn lookup_mut(&mut self, network: u16) -> Option<&mut RouteEntry>

Lookup a mutable route entry by network number.

Source

pub fn remove(&mut self, network: u16) -> Option<RouteEntry>

Remove a route.

Source

pub fn networks(&self) -> Vec<u16>

List all known network numbers.

Source

pub fn networks_not_on_port(&self, exclude_port: usize) -> Vec<u16>

List networks reachable via ports OTHER than exclude_port.

Source

pub fn networks_on_port(&self, port_index: usize) -> Vec<u16>

List networks reachable on a given port.

Source

pub fn len(&self) -> usize

Number of routes.

Source

pub fn is_empty(&self) -> bool

Whether the table is empty.

Source

pub fn touch(&mut self, network: u16)

Refresh the last_seen timestamp for a learned route.

Direct routes are unaffected since they never expire.

Source

pub fn purge_stale(&mut self, max_age: Duration) -> Vec<u16>

Remove learned routes that have not been refreshed within max_age.

Returns the network numbers that were purged.

Trait Implementations§

Source§

impl Clone for RouterTable

Source§

fn clone(&self) -> RouterTable

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for RouterTable

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for RouterTable

Source§

fn default() -> Self

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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