#[repr(transparent)]pub struct MacAddr6(_);Expand description
MAC address, represented as EUI-48
Implementations
sourceimpl MacAddr6
impl MacAddr6
pub const fn new(eui: [u8; 6]) -> Self
pub fn random() -> Self
rand only.pub const fn broadcast() -> Self
pub const fn nil() -> Self
sourcepub fn set_multicast(&mut self, v: bool)
pub fn set_multicast(&mut self, v: bool)
Sets multicast flag
sourcepub const fn is_multicast(&self) -> bool
pub const fn is_multicast(&self) -> bool
Returns the state of multicast flag
sourcepub const fn oui(&self) -> [u8; 3]
pub const fn oui(&self) -> [u8; 3]
Returns organizationally unique identifier (OUI) of this MAC address
sourcepub fn set_oui(&mut self, oui: [u8; 3])
pub fn set_oui(&mut self, oui: [u8; 3])
Sets organizationally unique identifier (OUI) for this MAC address
sourcepub const fn to_array(self) -> [u8; 6]
pub const fn to_array(self) -> [u8; 6]
Returns internal array representation for this MAC address, consuming it
sourcepub const fn as_slice(&self) -> &[u8]ⓘNotable traits for &[u8]impl Read for &[u8]impl Write for &mut [u8]
pub const fn as_slice(&self) -> &[u8]ⓘNotable traits for &[u8]impl Read for &[u8]impl Write for &mut [u8]
Returns internal array representation for this MAC address as u8 slice
sourcepub fn as_mut_slice(&mut self) -> &mut [u8]ⓘNotable traits for &[u8]impl Read for &[u8]impl Write for &mut [u8]
pub fn as_mut_slice(&mut self) -> &mut [u8]ⓘNotable traits for &[u8]impl Read for &[u8]impl Write for &mut [u8]
Returns internal array representation for this MAC address as mutable u8 slice
sourcepub const fn as_c_slice(&self) -> &[c_char]
pub const fn as_c_slice(&self) -> &[c_char]
Returns internal array representation for this MAC address as core::ffi::c_char slice.
This can be useful in parsing ifr_hwaddr, for example.
sourcepub const fn parse_str(s: &str) -> Result<Self, ParseError>
pub const fn parse_str(s: &str) -> Result<Self, ParseError>
Parse MAC address from string and return it as MacAddr.
This function can be used in const context, so MAC address can be parsed in compile-time.
sourcepub fn format_write<T: Write>(&self, f: &mut T, format: MacAddrFormat) -> Result
pub fn format_write<T: Write>(&self, f: &mut T, format: MacAddrFormat) -> Result
Write MAC address to impl core::fmt::Write, which can be used in no_std environments.
It can be used like this with arrayvec::ArrayString without allocations:
use arrayvec::ArrayString;
use advmac::{MacAddr6, MacAddrFormat, MAC_CANONICAL_SIZE6};
let mac = MacAddr6::parse_str("AA:BB:CC:DD:EE:FF").unwrap();
let mut buf = ArrayString::<MAC_CANONICAL_SIZE6>::new();
mac.format_write(&mut buf, MacAddrFormat::Canonical).unwrap();sourcepub fn format_string(&self, format: MacAddrFormat) -> String
Available on crate feature std only.
pub fn format_string(&self, format: MacAddrFormat) -> String
std only.Write MAC address to String. This function uses Self::format_write internally and produces the same result, but in string form, which can be convenient in non-constrainted environments.
sourceimpl MacAddr6
impl MacAddr6
pub const fn to_modified_eui64(self) -> MacAddr8
pub const fn try_from_modified_eui64(eui64: MacAddr8) -> Result<Self, IpError>
pub const fn to_link_local_ipv6(self) -> Ipv6Addr
std only.pub const fn try_from_link_local_ipv6(ip: Ipv6Addr) -> Result<Self, IpError>
std only.pub const fn try_from_multicast_ipv4(ip: Ipv4Addr) -> Result<Self, IpError>
std only.pub const fn try_from_multicast_ipv6(ip: Ipv6Addr) -> Result<Self, IpError>
std only.pub const fn try_from_multicast_ip(ip: IpAddr) -> Result<Self, IpError>
std only.Trait Implementations
sourceimpl<'de> Deserialize<'de> for MacAddr6
Available on crate feature serde only.
impl<'de> Deserialize<'de> for MacAddr6
serde only.sourcefn deserialize<D: Deserializer<'de>>(d: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(d: D) -> Result<Self, D::Error>
sourceimpl Ord for MacAddr6
impl Ord for MacAddr6
1.21.0 · sourcefn max(self, other: Self) -> Self
fn max(self, other: Self) -> Self
1.21.0 · sourcefn min(self, other: Self) -> Self
fn min(self, other: Self) -> Self
1.50.0 · sourcefn clamp(self, min: Self, max: Self) -> Selfwhere
Self: PartialOrd<Self>,
fn clamp(self, min: Self, max: Self) -> Selfwhere
Self: PartialOrd<Self>,
sourceimpl PartialOrd<MacAddr6> for MacAddr6
impl PartialOrd<MacAddr6> for MacAddr6
sourcefn partial_cmp(&self, other: &MacAddr6) -> Option<Ordering>
fn partial_cmp(&self, other: &MacAddr6) -> Option<Ordering>
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self and other) and is used by the <=
operator. Read more