pub struct MacAddress(pub [u8; 6]);Expand description
A 6-byte MAC address with display and parsing support.
Tuple Fields§
§0: [u8; 6]Implementations§
Source§impl MacAddress
impl MacAddress
pub const ZERO: Self
pub const BROADCAST: Self
Sourcepub const IPV4_MULTICAST_PREFIX: [u8; 3]
pub const IPV4_MULTICAST_PREFIX: [u8; 3]
Common multicast prefix for IPv4 (01:00:5e)
Sourcepub const IPV6_MULTICAST_PREFIX: [u8; 2]
pub const IPV6_MULTICAST_PREFIX: [u8; 2]
Common multicast prefix for IPv6 (33:33)
pub const fn new(bytes: [u8; 6]) -> Self
pub const fn as_bytes(&self) -> &[u8; 6]
pub const fn to_bytes(self) -> [u8; 6]
pub fn is_broadcast(&self) -> bool
pub fn is_multicast(&self) -> bool
pub fn is_unicast(&self) -> bool
pub fn is_local(&self) -> bool
pub fn is_zero(&self) -> bool
Sourcepub fn is_ipv4_multicast(&self) -> bool
pub fn is_ipv4_multicast(&self) -> bool
Check if this is an IPv4 multicast MAC (01:00:5e:xx:xx:xx)
Sourcepub fn is_ipv6_multicast(&self) -> bool
pub fn is_ipv6_multicast(&self) -> bool
Check if this is an IPv6 multicast MAC (33:33:xx:xx:xx:xx)
Sourcepub fn from_ipv4_multicast(ip: Ipv4Addr) -> Self
pub fn from_ipv4_multicast(ip: Ipv4Addr) -> Self
Create multicast MAC for IPv4 multicast address
Sourcepub fn from_ipv6_multicast(ip: Ipv6Addr) -> Self
pub fn from_ipv6_multicast(ip: Ipv6Addr) -> Self
Create multicast MAC for IPv6 multicast address
Sourcepub fn parse(s: &str) -> Result<Self, FieldError>
pub fn parse(s: &str) -> Result<Self, FieldError>
Parse MAC from string (e.g., “00:11:22:33:44:55” or “00-11-22-33-44-55”)
pub fn read_from(buf: &[u8], offset: usize) -> Result<Self, FieldError>
pub fn write_to(&self, buf: &mut [u8], offset: usize) -> Result<(), FieldError>
Trait Implementations§
Source§impl Clone for MacAddress
impl Clone for MacAddress
Source§fn clone(&self) -> MacAddress
fn clone(&self) -> MacAddress
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for MacAddress
impl Debug for MacAddress
Source§impl Default for MacAddress
impl Default for MacAddress
Source§fn default() -> MacAddress
fn default() -> MacAddress
Returns the “default value” for a type. Read more
Source§impl Display for MacAddress
impl Display for MacAddress
Source§impl Field for MacAddress
impl Field for MacAddress
Source§impl From<MacAddress> for [u8; 6]
impl From<MacAddress> for [u8; 6]
Source§fn from(mac: MacAddress) -> Self
fn from(mac: MacAddress) -> Self
Converts to this type from the input type.
Source§impl From<MacAddress> for FieldValue
impl From<MacAddress> for FieldValue
Source§fn from(v: MacAddress) -> Self
fn from(v: MacAddress) -> Self
Converts to this type from the input type.
Source§impl From<MacAddress> for HardwareAddr
impl From<MacAddress> for HardwareAddr
Source§fn from(mac: MacAddress) -> Self
fn from(mac: MacAddress) -> Self
Converts to this type from the input type.
Source§impl FromStr for MacAddress
impl FromStr for MacAddress
Source§impl Hash for MacAddress
impl Hash for MacAddress
Source§impl PartialEq for MacAddress
impl PartialEq for MacAddress
impl Copy for MacAddress
impl Eq for MacAddress
impl StructuralPartialEq for MacAddress
Auto Trait Implementations§
impl Freeze for MacAddress
impl RefUnwindSafe for MacAddress
impl Send for MacAddress
impl Sync for MacAddress
impl Unpin for MacAddress
impl UnsafeUnpin for MacAddress
impl UnwindSafe for MacAddress
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