cidr_util

Crates.iocidr_util
lib.rscidr_util
version0.1.0
sourcesrc
created_at2024-02-02 06:33:55.602727
updated_at2024-02-02 06:33:55.602727
descriptionA utility for calculation between Ipv4Addr/u32 and CIDR
homepage
repositoryhttps://github.com/xmh0511/cidr_util
max_upload_size
id1124036
size3,706
(xmh0511)

documentation

README

Example

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));
}
Commit count: 0

cargo fmt