Description
Implement IpV4Address as a ValueObject in the net module.
Spec: valid IPv4 (e.g. 192.168.1.1)
Implementation checklist
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() -> bool — true for RFC 1918 ranges (10.x, 172.16–31.x, 192.168.x).
is_loopback() -> bool — true for 127.x.x.x.
References
Description
Implement
IpV4Addressas aValueObjectin thenetmodule.Spec: valid IPv4 (e.g.
192.168.1.1)Implementation checklist
src/net/ipv4address.rsValueObjecttrait#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]src/net/mod.rsandprelude# ExampleblockROADMAP.mdfrom ⬜ to ✅Implementation detail
Input / Output
StringIpV4AddressInputString— canonical dotted-decimalIpV4AddressOutputNormalization
Parse with
std::net::Ipv4Addr, then re-serialise to itsDisplayform (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() -> bool—truefor RFC 1918 ranges (10.x, 172.16–31.x, 192.168.x).is_loopback() -> bool—truefor127.x.x.x.References