Skip to main content

AddressRotationHandler

Struct AddressRotationHandler 

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

Handler for BLE address rotation

Maintains mappings between device names and node IDs to handle address rotation gracefully.

Implementations§

Source§

impl AddressRotationHandler

Source

pub fn new() -> Self

Create a new address rotation handler

Source

pub fn register_device(&mut self, name: &str, address: &str, node_id: NodeId)

Register a new device

Creates mappings for name, address, and node ID.

Source

pub fn lookup_by_name(&self, name: &str) -> Option<NodeId>

Look up a device by name

Returns the node ID if the name is known.

Source

pub fn lookup_by_address(&self, address: &str) -> Option<NodeId>

Look up a device by address

Returns the node ID if the address is known.

Source

pub fn get_address(&self, node_id: &NodeId) -> Option<&String>

Get the current address for a node

Source

pub fn get_name(&self, node_id: &NodeId) -> Option<&String>

Get the name for a node

Source

pub fn on_device_discovered( &mut self, name: &str, address: &str, ) -> Option<DeviceLookupResult>

Handle a device discovery, detecting address rotation

This is the main entry point for handling discovered devices. It checks if we know this device by name and handles address rotation automatically.

Returns:

  • Some(DeviceLookupResult) if the device was found by name (existing device)
  • None if this is a new device
Source

pub fn update_address(&mut self, name: &str, new_address: &str) -> bool

Update the address for a device (used when address rotation is detected)

Source

pub fn update_name(&mut self, node_id: NodeId, new_name: &str)

Update the name for a device (e.g., when callsign is received)

Source

pub fn remove_device(&mut self, node_id: &NodeId)

Remove a device from all mappings

Source

pub fn clear(&mut self)

Clear all mappings

Source

pub fn device_count(&self) -> usize

Get the number of tracked devices

Source

pub fn stats(&self) -> AddressRotationStats

Get statistics about tracked mappings

Trait Implementations§

Source§

impl Debug for AddressRotationHandler

Source§

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

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

impl Default for AddressRotationHandler

Source§

fn default() -> AddressRotationHandler

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