#[repr(C)]pub struct MacAddr8(/* private fields */);
Expand description
MAC address in EUI-64 format.
Implementations§
Source§impl MacAddr8
impl MacAddr8
Sourcepub const fn new(
a: u8,
b: u8,
c: u8,
d: u8,
e: u8,
f: u8,
g: u8,
h: u8,
) -> MacAddr8
pub const fn new( a: u8, b: u8, c: u8, d: u8, e: u8, f: u8, g: u8, h: u8, ) -> MacAddr8
Creates a new MacAddr8
address from the bytes.
§Example
let addr = MacAddr8::new(0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF);
Sourcepub const fn broadcast() -> MacAddr8
pub const fn broadcast() -> MacAddr8
Create a new broadcast MacAddr8
.
§Example
let addr = MacAddr8::broadcast();
assert!(addr.is_broadcast());
Sourcepub fn is_nil(&self) -> bool
pub fn is_nil(&self) -> bool
Returns true
if the address is nil.
§Example
let addr = MacAddr8::new(0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00);
assert_eq!(addr.is_nil(), true);
Sourcepub fn is_broadcast(&self) -> bool
pub fn is_broadcast(&self) -> bool
Returns true
if the address is broadcast.
§Example
let addr = MacAddr8::new(0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF);
assert_eq!(addr.is_broadcast(), true);
Sourcepub const fn is_unicast(&self) -> bool
pub const fn is_unicast(&self) -> bool
Returns true
if the address is unicast.
§Example
let addr = MacAddr8::new(0x00, 0x01, 0x44, 0x55, 0x66, 0x77, 0xCD, 0xEF);
assert_eq!(addr.is_unicast(), true);
Sourcepub const fn is_multicast(&self) -> bool
pub const fn is_multicast(&self) -> bool
Returns true
if the address is multicast.
§Example
let addr = MacAddr8::new(0x01, 0x00, 0x0C, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC);
assert_eq!(addr.is_multicast(), true);
Sourcepub const fn is_universal(&self) -> bool
pub const fn is_universal(&self) -> bool
Returns true
if the address is universally administered address (UAA).
§Example
let addr = MacAddr8::new(0x01, 0x00, 0x0C, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC);
assert_eq!(addr.is_universal(), true);
Sourcepub const fn is_local(&self) -> bool
pub const fn is_local(&self) -> bool
Returns true
if the address is locally administered (LAA).
§Example
let addr = MacAddr8::new(0x02, 0x00, 0x0C, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC);
assert_eq!(addr.is_local(), true);
Sourcepub fn as_bytes(&self) -> &[u8] ⓘ
pub fn as_bytes(&self) -> &[u8] ⓘ
Converts a MacAddr8
address to a byte slice.
§Example
let addr = MacAddr8::new(0xAC, 0xDE, 0x48, 0x23, 0x45, 0x67, 0x89, 0xAB);
assert_eq!(addr.as_bytes(), &[0xAC, 0xDE, 0x48, 0x23, 0x45, 0x67, 0x89, 0xAB]);
Sourcepub const fn into_array(self) -> [u8; 8]
pub const fn into_array(self) -> [u8; 8]
Consumes a MacAddr8
address and returns raw bytes.
§Example
let addr = MacAddr8::new(0xAC, 0xDE, 0x48, 0x23, 0x45, 0x67, 0x89, 0xAB);
assert_eq!(addr.into_array(), [0xAC, 0xDE, 0x48, 0x23, 0x45, 0x67, 0x89, 0xAB]);
Trait Implementations§
Source§impl Display for MacAddr8
impl Display for MacAddr8
MacAddr8
can be displayed in different formats.
§Example
let addr = MacAddr8::new(0xab, 0x0d, 0xef, 0x12, 0x34, 0x56, 0x78, 0x9A);
assert_eq!(&format!("{}", addr), "AB:0D:EF:12:34:56:78:9A");
assert_eq!(&format!("{:-}", addr), "AB-0D-EF-12-34-56-78-9A");
assert_eq!(&format!("{:#}", addr), "AB0D.EF12.3456.789A");
Source§impl Ord for MacAddr8
impl Ord for MacAddr8
Source§impl PartialOrd for MacAddr8
impl PartialOrd for MacAddr8
impl Copy for MacAddr8
impl Eq for MacAddr8
impl StructuralPartialEq for MacAddr8
Auto Trait Implementations§
impl Freeze for MacAddr8
impl RefUnwindSafe for MacAddr8
impl Send for MacAddr8
impl Sync for MacAddr8
impl Unpin for MacAddr8
impl UnwindSafe for MacAddr8
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)