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:

§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, and Ipv6NetworkIterator.

Structs§

Enums§