pub struct NodeId { /* private fields */ }Expand description
Node identifier
Represents a unique node in the HIVE mesh. For BLE, this is typically derived from the Bluetooth MAC address or a configured value.
Implementations§
Source§impl NodeId
impl NodeId
Sourcepub fn from_mac_address(mac: &[u8; 6]) -> Self
pub fn from_mac_address(mac: &[u8; 6]) -> Self
Derive a NodeId from a BLE MAC address.
Uses the last 4 bytes of the 6-byte MAC address as the 32-bit node ID. This provides a consistent node ID derived from the device’s Bluetooth hardware address.
§Arguments
mac- 6-byte MAC address array (e.g., [0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF])
§Example
use hive_btle::NodeId;
let mac = [0x00, 0x11, 0x22, 0x33, 0x44, 0x55];
let node_id = NodeId::from_mac_address(&mac);
assert_eq!(node_id.as_u32(), 0x22334455);Sourcepub fn from_mac_string(mac_str: &str) -> Option<Self>
pub fn from_mac_string(mac_str: &str) -> Option<Self>
Derive a NodeId from a MAC address string.
Parses a MAC address in “AA:BB:CC:DD:EE:FF” format and derives the node ID from the last 4 bytes.
§Arguments
mac_str- MAC address string in colon-separated hex format
§Returns
Some(NodeId) if parsing succeeds, None otherwise
§Example
use hive_btle::NodeId;
let node_id = NodeId::from_mac_string("00:11:22:33:44:55").unwrap();
assert_eq!(node_id.as_u32(), 0x22334455);Trait Implementations§
Source§impl Ord for NodeId
impl Ord for NodeId
Source§impl PartialOrd for NodeId
impl PartialOrd for NodeId
impl Copy for NodeId
impl Eq for NodeId
impl StructuralPartialEq for NodeId
Auto Trait Implementations§
impl Freeze for NodeId
impl RefUnwindSafe for NodeId
impl Send for NodeId
impl Sync for NodeId
impl Unpin for NodeId
impl UnwindSafe for NodeId
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