#[repr(C)]pub struct MacAddr6(/* private fields */);
Expand description
MAC address in EUI-48 format.
Implementations§
Source§impl MacAddr6
impl MacAddr6
Sourcepub const fn new(a: u8, b: u8, c: u8, d: u8, e: u8, f: u8) -> MacAddr6
pub const fn new(a: u8, b: u8, c: u8, d: u8, e: u8, f: u8) -> MacAddr6
Creates a new MacAddr6
address from the bytes.
§Example
let addr = MacAddr6::new(0x01, 0x23, 0x45, 0x67, 0x89, 0xAB);
Sourcepub const fn broadcast() -> MacAddr6
pub const fn broadcast() -> MacAddr6
Create a new broadcast MacAddr6
.
§Example
let addr = MacAddr6::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 = MacAddr6::new(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 = MacAddr6::new(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 = MacAddr6::new(0x00, 0x01, 0x44, 0x55, 0x66, 0x77);
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 = MacAddr6::new(0x01, 0x00, 0x0C, 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 = MacAddr6::new(0x01, 0x00, 0x0C, 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 = MacAddr6::new(0x02, 0x00, 0x0C, 0xCC, 0xCC, 0xCC);
assert_eq!(addr.is_local(), true);
Sourcepub fn as_bytes(&self) -> &[u8] ⓘ
pub fn as_bytes(&self) -> &[u8] ⓘ
Converts a MacAddr6
address to a byte slice.
§Example
let addr = MacAddr6::new(0xAC, 0xDE, 0x48, 0x23, 0x45, 0x67);
assert_eq!(addr.as_bytes(), &[0xAC, 0xDE, 0x48, 0x23, 0x45, 0x67]);
Sourcepub const fn into_array(self) -> [u8; 6]
pub const fn into_array(self) -> [u8; 6]
Consumes MacAddr6
address and returns raw bytes array.
§Example
let addr = MacAddr6::new(0xAC, 0xDE, 0x48, 0x23, 0x45, 0x67);
assert_eq!(addr.into_array(), [0xAC, 0xDE, 0x48, 0x23, 0x45, 0x67]);
Trait Implementations§
Source§impl Display for MacAddr6
impl Display for MacAddr6
MacAddr6
can be displayed in different formats.
§Example
let addr = MacAddr6::new(0xab, 0x0d, 0xef, 0x12, 0x34, 0x56);
assert_eq!(&format!("{}", addr), "AB:0D:EF:12:34:56");
assert_eq!(&format!("{:-}", addr), "AB-0D-EF-12-34-56");
assert_eq!(&format!("{:#}", addr), "AB0.DEF.123.456");
Source§impl Ord for MacAddr6
impl Ord for MacAddr6
Source§impl PartialOrd for MacAddr6
impl PartialOrd for MacAddr6
impl Copy for MacAddr6
impl Eq for MacAddr6
impl StructuralPartialEq for MacAddr6
Auto Trait Implementations§
impl Freeze for MacAddr6
impl RefUnwindSafe for MacAddr6
impl Send for MacAddr6
impl Sync for MacAddr6
impl Unpin for MacAddr6
impl UnwindSafe for MacAddr6
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
)