Skip to main content

Crate use_cidr

Crate use_cidr 

Source
Expand description

§use-cidr

use-cidr provides small helpers for parsing CIDR notation and validating prefix lengths.

Experimental: this crate is below 0.3.0 and the API may change.

§Example Usage

use use_cidr::{format_cidr, parse_cidr};

let block = parse_cidr("192.168.0.0/24").unwrap();

assert_eq!(block.prefix, 24);
assert_eq!(format_cidr(&block), "192.168.0.0/24");

§Scope

  • CIDR parsing for IPv4 and IPv6 blocks.
  • Prefix-length validation helpers.

§Non-goals

  • Full subnet math.
  • Route table implementation.
  • IP range expansion.
  • Firewall logic.

§License

Licensed under MIT OR Apache-2.0.

Structs§

CidrBlock
Stores a parsed CIDR block.

Functions§

format_cidr
Formats a CIDR block.
is_cidr
Returns true when the input is a valid IPv4 or IPv6 CIDR block.
is_ipv4_cidr
Returns true when the input is a valid IPv4 CIDR block.
is_ipv6_cidr
Returns true when the input is a valid IPv6 CIDR block.
is_valid_ipv4_prefix
Returns true when the prefix is valid for IPv4.
is_valid_ipv6_prefix
Returns true when the prefix is valid for IPv6.
parse_cidr
Parses a CIDR block from text.