cidr-radix 11.2.0

Zero-dependency, zero-allocation IPv4/IPv6 CIDR parsing, bitmask matching, canonicalization, and radix-indexed IpCidrSet lookup.
Documentation
use super::*;

/// Radix-indexed, interval-coalesced IPv4/IPv6 CIDR set for O(1)/O(log k) membership lookup.
#[derive(Clone, Debug, Default, Eq, PartialEq)]
pub struct IpCidrSet {
    /// Sorted, disjoint, coalesced IPv4 `[start, end]` ranges.
    pub(crate) v4_ranges: Vec<(u32, u32)>,
    /// Fixed 256-entry `/8` radix directory for IPv4 ranges (`None` when empty or wildcard).
    pub(crate) v4_buckets: RadixBuckets,
    /// Adaptive L2 sub-tables backing dense IPv4 `/8` buckets.
    pub(crate) v4_sub_buckets: Vec<u64>,
    /// Fast-path flag indicating full `0.0.0.0/0` coverage.
    pub(crate) v4_any: bool,
    /// Sorted, disjoint, coalesced IPv6 `[start, end]` ranges.
    pub(crate) v6_ranges: Vec<(u128, u128)>,
    /// Fixed 256-entry `/8` radix directory for IPv6 ranges (`None` when empty or wildcard).
    pub(crate) v6_buckets: RadixBuckets,
    /// Common-prefix adaptive sub-table descriptors `(prefix_val, prefix_mask, shift_and_mask, offset)`.
    pub(crate) v6_sub_meta: Vec<V6SubTableMeta>,
    /// Adaptive L2 sub-tables backing dense IPv6 `/8` buckets.
    pub(crate) v6_sub_buckets: Vec<u64>,
    /// Fast-path flag indicating full `::/0` coverage.
    pub(crate) v6_any: bool,
}

/// Incremental builder for constructing an optimized `IpCidrSet`.
#[derive(Clone, Debug, Default)]
pub struct IpCidrSetBuilder {
    /// Unsorted raw IPv4 `[start, end]` intervals collected prior to coalescing.
    pub(crate) v4_raw: Vec<(u32, u32)>,
    /// Unsorted raw IPv6 `[start, end]` intervals collected prior to coalescing.
    pub(crate) v6_raw: Vec<(u128, u128)>,
}