pub struct DeviceTable { /* private fields */ }Expand description
Thread-safe device discovery table.
Keyed by device instance number (the instance part of the DEVICE object identifier). Updated whenever an IAm is received.
Implementations§
Source§impl DeviceTable
impl DeviceTable
pub fn new() -> Self
Sourcepub fn upsert(&mut self, device: DiscoveredDevice)
pub fn upsert(&mut self, device: DiscoveredDevice)
Insert or update a discovered device.
The table is capped at 4096 entries. If the table is full and the device is not already present, the new entry is silently dropped.
Sourcepub fn all(&self) -> Vec<DiscoveredDevice>
pub fn all(&self) -> Vec<DiscoveredDevice>
Get all discovered devices as a snapshot.
Sourcepub fn get(&self, instance: u32) -> Option<&DiscoveredDevice>
pub fn get(&self, instance: u32) -> Option<&DiscoveredDevice>
Look up a device by instance number.
Sourcepub fn get_by_mac(&self, mac: &[u8]) -> Option<&DiscoveredDevice>
pub fn get_by_mac(&self, mac: &[u8]) -> Option<&DiscoveredDevice>
Look up a device by its MAC address.
Sourcepub fn purge_stale(&mut self, max_age: Duration)
pub fn purge_stale(&mut self, max_age: Duration)
Remove entries whose last_seen is older than max_age.
Trait Implementations§
Source§impl Debug for DeviceTable
impl Debug for DeviceTable
Source§impl Default for DeviceTable
impl Default for DeviceTable
Source§fn default() -> DeviceTable
fn default() -> DeviceTable
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for DeviceTable
impl RefUnwindSafe for DeviceTable
impl Send for DeviceTable
impl Sync for DeviceTable
impl Unpin for DeviceTable
impl UnsafeUnpin for DeviceTable
impl UnwindSafe for DeviceTable
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more