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§
- Various error types returned by function in this crate
- Extra parsers
Structs§
- Iterator type to iterate over a list of IP addresses in a network
- Iterator type to iterate over a list of IP addresses within a network
Cidrtype representing an IPv4 networkInettype representing an IPv4 host within a networkInetPairtype representing a pair of IPv4 hosts within a networkCidrtype representing an IPv6 networkInettype representing an IPv6 host within a networkInetPairtype representing a pair of IPv6 hosts within a network
Enums§
- Represents either an IPv4 or an IPv6 network or “any”.
- Represents the type of an IP address
Cidrtype representing either an IPv4 or an IPv6 networkInettype representing either an IPv4 or an IPv6 host within a networkInetPairtype representing either a pair of IPv4 host or a pair of IPv6 hosts within a network
Traits§
- Maps IP address type to other types based on this address type
- 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. - Types implementing Inet represent IP hosts within networks.
- Pair of two addresses in the same network