Crate ip_network
source ·Expand description
IPv4 and IPv6 network structs.
Optional features
When using this crate, you can choose to compile with these features:
serde
– for serialization and deserialization by Serde framework.diesel
– support for PostgreSQL CIDR type with Diesel ORM.postgres
– support for PostgreSQL CIDR type with postgres crate.
Examples
use std::net::Ipv4Addr;
use ip_network::Ipv4Network;
let ip_network = Ipv4Network::new(Ipv4Addr::new(192, 168, 1, 0), 24)?;
assert_eq!(Ipv4Addr::new(192, 168, 1, 0), ip_network.network_address());
assert_eq!(24, ip_network.netmask());
assert_eq!(254, ip_network.hosts().len());
assert_eq!("192.168.1.0/24", ip_network.to_string());
Modules
Ipv4RangeIterator
,Ipv4NetworkIterator
, andIpv6NetworkIterator
.
Structs
- IPv4 Network.
- IPv6 Network.
Enums
- Holds IPv4 or IPv6 network.
- Errors when creating new IPv4 or IPv6 networks.
- Errors from IPv4 or IPv6 network parsing.
- IPv6 Multicast Address Scopes.