Description
Implement MacAddress as a ValueObject in the net module.
Spec: 6-byte MAC, normalised to lowercase colon-separated hex
Implementation checklist
Implementation detail
Input / Output
|
Type |
Alias |
| Input |
String |
MacAddressInput |
| Output |
String — lowercase colon-separated, e.g. "aa:bb:cc:dd:ee:ff" |
MacAddressOutput |
Normalization
Strip all : and - separators; lowercase; then format as 6 pairs of hex digits separated by colons.
Validation
- After stripping separators, must be exactly 12 hexadecimal characters (6 bytes).
Extra methods
bytes() -> [u8; 6] — the 6 raw bytes.
is_broadcast() -> bool — true if all bytes are 0xff.
is_multicast() -> bool — true if the least-significant bit of the first byte is 1 (IEEE multicast bit).
References
Description
Implement
MacAddressas aValueObjectin thenetmodule.Spec: 6-byte MAC, normalised to lowercase colon-separated hex
Implementation checklist
src/net/macaddress.rsValueObjecttrait#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]src/net/mod.rsandprelude# ExampleblockROADMAP.mdfrom ⬜ to ✅Implementation detail
Input / Output
StringMacAddressInputString— lowercase colon-separated, e.g."aa:bb:cc:dd:ee:ff"MacAddressOutputNormalization
Strip all
:and-separators; lowercase; then format as 6 pairs of hex digits separated by colons.Validation
Extra methods
bytes() -> [u8; 6]— the 6 raw bytes.is_broadcast() -> bool—trueif all bytes are0xff.is_multicast() -> bool—trueif the least-significant bit of the first byte is 1 (IEEE multicast bit).References