Skip to main content

MacAddress

Struct MacAddress 

Source
pub struct MacAddress(/* private fields */);
Expand description

Mac Address

Implementations§

Source§

impl MacAddress

Source

pub const fn new(mac: [u8; 6]) -> Self

Construct a new MacAddress instance

Source

pub const fn new6(a: u8, b: u8, c: u8, d: u8, e: u8, f: u8) -> Self

Construct a new MacAddress instance from 6 components

Source

pub const fn from_slice(mac: &[u8]) -> Result<Self, ParseMacError>

Construct a new MacAddress instance from slice

Source

pub const fn zero() -> Self

Construct an all-zero MacAddr instance.

Source

pub const fn broadcast() -> Self

Construct a broadcast MacAddr instance.

Source

pub fn is_zero(&self) -> bool

Returns true if a MacAddr is an all-zero address.

Source

pub fn is_universal(&self) -> bool

Returns true if the MacAddr is a universally administered addresses (UAA).

Source

pub fn is_local(&self) -> bool

Returns true if the MacAddr is a locally administered addresses (LAA).

Source

pub fn is_unicast(&self) -> bool

Returns true if the MacAddr is a unicast address.

Source

pub fn is_multicast(&self) -> bool

Returns true if the MacAddr is a multicast address.

Source

pub fn is_broadcast(&self) -> bool

Returns true if the MacAddr is a broadcast address.

Source

pub fn octets(&self) -> [u8; 6]

Source

pub fn to_u64(&self) -> u64

Trait Implementations§

Source§

impl Clone for MacAddress

Source§

fn clone(&self) -> MacAddress

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for MacAddress

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for MacAddress

Source§

fn default() -> MacAddress

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for MacAddress

Available on crate feature serde only.
Source§

fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>

Deserializes the MAC address.

It deserializes it from either a byte array (of size 6) or a string. If the format is self-descriptive (like JSON or MessagePack), it auto-detects it. If not, it obeys the human-readable property of the deserializer.

Source§

impl Display for MacAddress

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl From<[u8; 6]> for MacAddress

Source§

fn from(value: [u8; 6]) -> Self

Converts to this type from the input type.
Source§

impl From<MacAddr> for MacAddress

Available on crate feature pnet only.
Source§

fn from(value: MacAddr) -> Self

Converts to this type from the input type.
Source§

impl FromStr for MacAddress

Source§

fn from_str(s: &str) -> Result<Self, Self::Err>

parse mac address, e.g. 52:54:00:12:34:56 or 52-54-00-12-34-56

Source§

type Err = ParseMacError

The associated error which can be returned from parsing.
Source§

impl Hash for MacAddress

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Ord for MacAddress

Source§

fn cmp(&self, other: &MacAddress) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 (const: unstable) · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 (const: unstable) · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for MacAddress

Source§

fn eq(&self, other: &MacAddress) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for MacAddress

Source§

fn partial_cmp(&self, other: &MacAddress) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Serialize for MacAddress

Available on crate feature serde only.
Source§

fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error>

Serializes the MAC address.

It serializes either to a string or its binary representation, depending on what the format prefers.

Source§

impl Sub for &MacAddress

Source§

type Output = i64

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Self) -> Self::Output

Performs the - operation. Read more
Source§

impl Sub for MacAddress

Source§

type Output = i64

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Self) -> Self::Output

Performs the - operation. Read more
Source§

impl TryFrom<&[u8]> for MacAddress

Source§

type Error = ParseMacError

The type returned in the event of a conversion error.
Source§

fn try_from(value: &[u8]) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<&str> for MacAddress

Source§

type Error = ParseMacError

The type returned in the event of a conversion error.
Source§

fn try_from(value: &str) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Cow<'_, str>> for MacAddress

Available on crate feature std only.
Source§

type Error = ParseMacError

The type returned in the event of a conversion error.
Source§

fn try_from(value: Cow<'_, str>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl Copy for MacAddress

Source§

impl Eq for MacAddress

Source§

impl StructuralPartialEq for MacAddress

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,