cidr-radix 11.2.0

Zero-dependency, zero-allocation IPv4/IPv6 CIDR parsing, bitmask matching, canonicalization, and radix-indexed IpCidrSet lookup.
Documentation
/// Number of first-octet radix buckets (`0..=255`).
pub(crate) const RADIX_BUCKET_COUNT: usize = 256;

/// Packed bucket sentinel indicating no CIDR ranges intersect the bucket.
pub(crate) const BUCKET_EMPTY: u64 = 0;

/// Packed bucket sentinel indicating the entire bucket is covered.
pub(crate) const BUCKET_FULL: u64 = 1u64 << 61;

/// Tag bit indicating an inline single IPv4 range packed directly in the bucket word.
pub(crate) const BUCKET_INLINE_FLAG: u64 = 1u64 << 63;

/// Tag bit indicating the bucket points to an adaptive L2 sub-table.
pub(crate) const BUCKET_SUBTABLE_FLAG: u64 = 1u64 << 62;

/// Mask extracting the lower 32-bit start index or sub-table offset from a packed bucket entry.
pub(crate) const BUCKET_LO_MASK: u64 = 0xFFFF_FFFF;

/// Bit shift for packing the upper 32-bit end index into a slice bucket entry.
pub(crate) const BUCKET_HI_SHIFT: u32 = 32;

/// Bit shift to extract the first octet of an IPv4 address.
pub(crate) const IPV4_FIRST_OCTET_SHIFT: u32 = 24;

/// Host-bit mask within a single IPv4 `/8` bucket.
pub(crate) const IPV4_BUCKET_HOST_MASK: u32 = 0x00FF_FFFF;

/// Bit shift for the upper 24-bit host bound in an inline IPv4 bucket entry.
pub(crate) const IPV4_INLINE_HI_SHIFT: u32 = 24;

/// Bit position of the 6-bit sub-table right-shift field inside an IPv4 L1 sub-table entry.
pub(crate) const SUBTABLE_SHIFT_POS: u32 = 56;

/// Mask extracting the 6-bit sub-table right-shift value.
pub(crate) const SUBTABLE_SHIFT_MASK: u64 = 0x3F;

/// Bit position of the sub-table index mask field inside an IPv4 L1 sub-table entry.
pub(crate) const SUBTABLE_MASK_POS: u32 = 32;

/// Mask extracting the 24-bit sub-table index mask field.
pub(crate) const SUBTABLE_MASK_BITS: u64 = 0x00FF_FFFF;

/// Minimum range count inside a `/8` bucket required to promote to an L2 sub-table.
pub(crate) const SUBTABLE_MIN_RANGES: usize = 8;

/// Range-count threshold selecting a medium 256-entry L2 sub-table.
pub(crate) const SUBTABLE_MEDIUM_RANGES: usize = 64;

/// Range-count threshold selecting a large L2 sub-table.
pub(crate) const SUBTABLE_LARGE_RANGES: usize = 512;

/// Stride bits for a small 16-entry L2 sub-table (`2^4`).
pub(crate) const SUBTABLE_SMALL_BITS: u32 = 4;

/// Stride bits for a medium 256-entry L2 sub-table (`2^8`).
pub(crate) const SUBTABLE_MEDIUM_BITS: u32 = 8;

/// Stride bits for a large 2048-entry IPv4 L2 sub-table (`2^11`).
pub(crate) const SUBTABLE_LARGE_BITS_V4: u32 = 11;

/// Stride bits for a large 1024-entry IPv6 L2 sub-table (`2^10`).
pub(crate) const SUBTABLE_LARGE_BITS_V6: u32 = 10;

/// Bit shift to extract the first byte of an IPv6 address.
pub(crate) const IPV6_FIRST_BYTE_SHIFT: u32 = 120;

/// Host-bit mask within a single IPv6 `/8` bucket.
pub(crate) const IPV6_BUCKET_HOST_MASK: u128 = (1u128 << 120) - 1;

/// Mask extracting the 8-bit shift value from packed IPv6 sub-table metadata.
pub(crate) const IPV6_META_SHIFT_MASK: u32 = 0xFF;

/// Bit position of the sub-table index mask in packed IPv6 sub-table metadata.
pub(crate) const IPV6_META_MASK_POS: u32 = 8;

/// Threshold below which linear scan beats binary search inside a radix bucket.
pub(crate) const LINEAR_SCAN_THRESHOLD: usize = 4;