pub fn parse_short_ipv4_address_as_cidr(
s: &str,
) -> Result<Ipv4Cidr, NetworkParseError>
Expand description
Parse “short” IPv4 addresses as networks with octet-aligned length
- parse
"10"
as10.0.0.0/8
- parse
"192.168"
as192.168.0.0/16
- parse
"192.0.2"
as192.0.2.0/24
- parse
"127"
as127.0.0.0/8
- parse
"127.0.0.1"
as127.0.0.1/32
The returned prefix length indicates how many octets were present.
This is very different from inet_addr
which would
interpret "192.168"
as 192.0.0.168
!
This function doesn’t accept normal CIDR notations, so you will probably need to combine it with other functions.