Crate ipnet [−] [src]
Types for IPv4 and IPv6 network addresses.
This module provides types and useful methods for working with IPv4
and IPv6 network addresses, commonly called IP prefixes. The new
IpNet
, Ipv4Net
, and Ipv6Net
types build on the existing
IpAddr
, Ipv4Addr
, and Ipv6Addr
types already provided in
Rust's standard library and align to their design to stay
consistent.
The module also provides types for iterating over IP address ranges,
and useful traits that extend Ipv4Addr
and Ipv6Addr
with
methods for addition, subtraction, bitwise-and, and bitwise-or
operations that are missing in Rust's standard library.
The module only uses stable features so it is guaranteed to compile using the stable toolchain.
Organization
IpNet
represents an IP network address, either IPv4 or IPv6.Ipv4Net
andIpv6Net
are respectively IPv4 and IPv6 network addresses.IpSubnets
,Ipv4Subnets
, andIpv6Subnets
are iterators that generate the smallest set of IP network addresses bound by an IP address range and minimum prefix length. These are returned by thesubnets()
methods and used in theaggregate()
methods.IpAddrRange
,Ipv4AddrRange
, andIpv6AddrRange
provide iteration over ranges of IP addresses. These are returned by thehosts()
methods.- The
IpAdd
,IpSub
,IpBitAnd
,IpBitOr
traits extend theIpv4Addr
andIpv6Addr
types with methods to perform these operations. Emu128
is an emulated 128 bit unsigned integer implemented in this module using a struct of twou64
types. This is useful for operations on IPv6 address, which are 128 bit unsigned integers.
Serde support
This library comes with support for serde but it's
not enabled by default. Use the with-serde
feature to enable.
Structs
AddrParseError |
An error which can be returned when parsing an IP network address. |
Emu128 |
An emulated 128 bit unsigned integer. |
Ipv4AddrRange |
An |
Ipv4Net |
An IPv4 network address. |
Ipv4Subnets |
An |
Ipv6AddrRange |
An |
Ipv6Net |
An IPv6 network address. |
Ipv6Subnets |
An |
PrefixLenError |
An error which can be returned when the prefix length is invalid. |
Enums
IpAddrRange |
An |
IpNet |
An IP network address, either IPv4 or IPv6. |
IpSubnets |
An |
Traits
Contains |
Provides a method to test if a network address contains either another network address or another IP address. |
IpAdd |
Provides a |
IpBitAnd |
Provides a |
IpBitOr |
Provides a |
IpSub |
Provides a |