pub struct MacAddr6(/* private fields */);Expand description
MAC address, represented as EUI-48
Implementations§
Source§impl 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] ⓘ
pub const fn as_slice(&self) -> &[u8] ⓘ
Returns internal array representation for this MAC address as u8 slice
Sourcepub fn as_mut_slice(&mut self) -> &mut [u8] ⓘ
pub fn as_mut_slice(&mut self) -> &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.
Source§impl 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§
Source§impl<'de> Deserialize<'de> for MacAddr6
Available on crate feature serde only.
impl<'de> Deserialize<'de> for MacAddr6
serde only.