const EXTENDED_ADDRESS_SIZE: usize = 8;
pub struct ExtendedAddress([u8; EXTENDED_ADDRESS_SIZE]);
impl ExtendedAddress {
pub fn random() -> Self {
let mut bytes = [0u8; EXTENDED_ADDRESS_SIZE];
crate::fill_random_bytes(&mut bytes);
Self(bytes)
}
}
impl From<ExtendedAddress> for u64 {
fn from(value: ExtendedAddress) -> Self {
u64::from_be_bytes(value.0)
}
}
impl From<u64> for ExtendedAddress {
fn from(extended_address: u64) -> Self {
Self(extended_address.to_be_bytes())
}
}
impl core::fmt::Display for ExtendedAddress {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
for byte in &self.0 {
write!(f, "{:02x}", byte)?;
}
Ok(())
}
}