Skip to content

Add IpV4Address (net) #48

@vhrcgcom

Description

@vhrcgcom

Description

Implement IpV4Address as a ValueObject in the net module.

Spec: valid IPv4 (e.g. 192.168.1.1)

Implementation checklist

  • Create src/net/ipv4address.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 IpV4AddressInput
Output String — canonical dotted-decimal IpV4AddressOutput

Normalization

Parse with std::net::Ipv4Addr, then re-serialise to its Display form (canonical dotted-decimal, no leading zeros).

Validation

Must parse successfully via std::net::Ipv4Addr::from_str. Leading zeros in octets are rejected (e.g. "192.168.01.1" is invalid — they cause ambiguity with octal notation).

Extra methods

  • octets() -> [u8; 4]
  • is_private() -> booltrue for RFC 1918 ranges (10.x, 172.16–31.x, 192.168.x).
  • is_loopback() -> booltrue for 127.x.x.x.

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions