| Crates.io | cidr_util |
| lib.rs | cidr_util |
| version | 0.1.0 |
| created_at | 2024-02-02 06:33:55.602727+00 |
| updated_at | 2024-02-02 06:33:55.602727+00 |
| description | A utility for calculation between Ipv4Addr/u32 and CIDR |
| homepage | |
| repository | https://github.com/xmh0511/cidr_util |
| max_upload_size | |
| id | 1124036 |
| size | 3,706 |
use cidr_util::{Cidr, CidrPrefix};
fn main(){
assert_eq!(24, Ipv4Addr::new(255, 255, 255, 0).to_prefix_len());
assert_eq!(
(Ipv4Addr::new(10, 0, 0, 0), Ipv4Addr::new(10, 0, 0, 255)),
Ipv4Addr::new(10, 0, 0, 0).ip_range(24)
);
assert_eq!(24.to_subnet_mask(), Ipv4Addr::new(255, 255, 255, 0));
assert_eq!(1.to_subnet_mask(), Ipv4Addr::new(128, 0, 0, 0));
}