Crate ipnet [−] [src]
Types for IPv4 and IPv6 network addresses.
This module provides types and methods for working with IPv4 and
IPv6 network addresses. It aims for alignment with the IpAddr,
Ipv4Addr, and Ipv6Addr types in Rust's standard library.
The module also provides traits that extend Ipv4Addr and
Ipv6Addr to support Add, Sub, BitAnd, and BitOr operations.
Organization
IpNetrepresents IP network addresses of either IPv4 or IPv6.Ipv4NetandIpv6Netare respectively IPv4 and IPv6 network addresses.- The
IpAdd,IpSub,IpBitAnd,IpBitOrtraits extend theIpv4AddrandIpv6Addrtypes to include these operations. Emu128is an emulated 128 bit unsigned integer implemented in this module using a struct of twou64types. This is necessary because Rust'su128type is not yet marked stable. This can be replaced whenu128is stable.
TODO:
- Should we convert subnets() and aggregate() methods to iterators?
- Should new() truncate the input Ipv4Addr to the prefix_len and store that instead? Technically it doesn't matter, but users may expect one behavior over the other.
- Should new() precompute the netmask, hostmask, network, and broadcast addresses and store these to avoid recomputing everytime the methods are called?
- Can we implement the
std::ops::{Add, Sub, BitAnd, BitOr}traits forIpv4AddrandIpv6Addrin the standard library? These are common operations on IP addresses. - Explore the possibility of representing IP network addresses as a
Rangeusing Rust'sRangeArgumenttrait.RangeArgumentand many of the associatedRangemethods are still nightly-only experimental APIs.
Structs
| AddrParseError |
An error which can be returned when parsing an IP network address. |
| Emu128 |
An emulated 128 bit unsigned integer. |
| IpAddrIter |
An |
| Ipv4Net |
An IPv4 network address. |
| Ipv4NetIterator | |
| Ipv6Net |
An IPv6 network address. |
| Ipv6NetIterator |
Enums
| IpNet |
An IP network address, either IPv4 or IPv6. |
Traits
| IpAdd |
Provides a |
| IpBitAnd |
Provides a |
| IpBitOr |
Provides a |
| IpSub |
Provides a |