openthread/ot/types/
ext_address.rsuse crate::prelude_internal::*;
#[derive(Default, Copy, Clone)]
#[repr(transparent)]
pub struct ExtAddress(pub otExtAddress);
impl_ot_castable!(ExtAddress, otExtAddress);
impl std::fmt::Debug for ExtAddress {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "ExtAddress({})", hex::encode(self.as_slice()))
}
}
impl std::fmt::Display for ExtAddress {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", hex::encode(self.as_slice()))
}
}
impl std::convert::From<[u8; 8]> for ExtAddress {
fn from(value: [u8; 8]) -> Self {
Self(otExtAddress { m8: value })
}
}
impl ExtAddress {
pub fn into_array(self) -> [u8; 8] {
self.0.m8
}
pub fn as_slice(&self) -> &[u8] {
&self.0.m8
}
pub fn to_vec(&self) -> Vec<u8> {
self.as_slice().to_vec()
}
}