Skip to content

Add MacAddress (net) #52

@vhrcgcom

Description

@vhrcgcom

Description

Implement MacAddress as a ValueObject in the net module.

Spec: 6-byte MAC, normalised to lowercase colon-separated hex

Implementation checklist

  • Create src/net/macaddress.rs
  • Implement ValueObject trait
  • Add #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
  • Export from src/net/mod.rs and prelude
  • Unit tests: valid input · empty input · invalid format · normalisation
  • Doc comment with # Example block
  • Update status in ROADMAP.md from ⬜ to ✅

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() -> booltrue if all bytes are 0xff.
  • is_multicast() -> booltrue if the least-significant bit of the first byte is 1 (IEEE multicast bit).

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or improvement

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions