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
Address parsing also accepts IPv4 address with less than four octets (but always parses those as decimal); this is deprecated and will be removed in 0.3.0.
If the #
flag is used with the Display
formatting (i.e. {:#}
) the
prefix 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, also mandatory right now because std::net
isn’t
available in core
.
§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 lengthtag
0x40...0xc0
: IPv6 with network lengthtag - 0x40
0xff
: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
Cidr
type representing an IPv4 networkInet
type representing an IPv4 host within a networkInetPair
type representing a pair of IPv4 hosts within a networkCidr
type representing an IPv6 networkInet
type representing an IPv6 host within a networkInetPair
type 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
Cidr
type representing either an IPv4 or an IPv6 networkInet
type representing either an IPv4 or an IPv6 host within a networkInetPair
type 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
Cidr
represent 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