Expand description
This library provides types to represent an IP network (Cidr) or
an IP host withing a network (Inet)
The naming follows the names of the PostgreSQL data types
By default address parsing is done using FromStr from the standard
library, which is rather strict in the inputs it accepts.
Cidr types don’t accept addresses with host-bits set (i.e. 127.0.0.1/8
isn’t valid; it should be 127.0.0.0/8).
Custom parsing can be implemented using the helpers in the parsers module.
If the # flag is used with the Display formatting (i.e. {:#}) the
prefix length will be shown even for host addresses (added in 0.1.1).
§Feature no_unsafe
Enables #![forbid(unsafe_code)] for the whole crate; needs to use
some workarounds that are likely slower than their unsafe variants.
§Feature std
Enabled by default, currently unused.
§Feature serde
This feature enables various types to be serialized using serde
(without serde-derive).
In human readable formats the Display and FromStr interfaces are
used. Otherwise all values are serialized in the same format (apart
from the newtype wrapping) as a tuple of two values:
tag: u8:0x00...0x20: IPv4 with network lengthtag0x40...0xc0: IPv6 with network lengthtag - 0x400xff:any
- address according to
tag:Ipv4Addr([u8; 4]),Ipv6Addr([u8; 16]) or()
The represenation hasn’t been changed in 0.2; it is compatible with 0.1.
§Feature bitstring
This feature allows various types to be used as bitstring::BitString,
which allows them being in used in containers like bitstring-trees.
Modules§
Structs§
- Inet
Address Iterator - Iterator type to iterate over a list of IP addresses in a network
- Inet
Iterator - Iterator type to iterate over a list of IP addresses within a network
- Ipv4
Cidr Cidrtype representing an IPv4 network- Ipv4
Inet Inettype representing an IPv4 host within a network- Ipv4
Inet Pair InetPairtype representing a pair of IPv4 hosts within a network- Ipv6
Cidr Cidrtype representing an IPv6 network- Ipv6
Inet Inettype representing an IPv6 host within a network- Ipv6
Inet Pair InetPairtype representing a pair of IPv6 hosts within a network
Enums§
- AnyIp
Cidr - Represents either an IPv4 or an IPv6 network or “any”.
- Family
- Represents the type of an IP address
- IpCidr
Cidrtype representing either an IPv4 or an IPv6 network- IpInet
Inettype representing either an IPv4 or an IPv6 host within a network- IpInet
Pair InetPairtype representing either a pair of IPv4 host or a pair of IPv6 hosts within a network
Traits§
- Address
- Maps IP address type to other types based on this address type
- Cidr
- Types implementing
Cidrrepresent IP networks. An IP network in this case is a set of IP addresses which share a common prefix (when viewed as a bitstring). The length of this prefix is callednetwork_length. - Inet
- Types implementing Inet represent IP hosts within networks.
- Inet
Pair - Pair of two addresses in the same network