Crates.io | subnetwork |
lib.rs | subnetwork |
version | 0.4.8 |
source | src |
created_at | 2023-06-08 11:52:29.455599 |
updated_at | 2024-11-22 02:02:30.004146 |
description | Return all ip addresses of a subnetwork |
homepage | https://github.com/rikonaka/subnetwork-rs |
repository | https://github.com/rikonaka/subnetwork-rs |
max_upload_size | |
id | 885439 |
size | 34,813 |
Returns an iterator that iterates over all subnet IPs.
use std::net::Ipv4Addr;
use subnetwork::Ipv4Pool;
fn main() {
let ipv4_pool = Ipv4Pool::from("192.168.1.0/24").unwrap();
for i in ipv4_pool {
println!("{:?}", i);
}
let ipv4 = Ipv4Addr::new(192, 168, 1, 1);
let ret = ipv4_pool.contain(ipv4);
assert_eq!(ret, true);
}
use std::net::Ipv4Addr;
use subnetwork::CrossIpv4Pool;
fn main() {
let start = Ipv4Addr::new(192, 168, 1, 1);
let end = Ipv4Addr::new(192, 168, 3, 254);
let ips = CrossIpv4Pool::new(start, end).unwrap();
for i in ips {
println!("{:?}", i);
}
}
You can see how our performance compares to other similar libraries here.