cidr-radix 11.2.0

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

/// Formats `IpCidrError` variants as human-readable messages.
impl fmt::Display for IpCidrError {
    /// Writes the error description to the given formatter.
    ///
    /// # Arguments
    ///
    /// - `&Self` - The error variant to format.
    /// - `&mut fmt::Formatter<'_>` - The target formatter.
    ///
    /// # Returns
    ///
    /// - `fmt::Result` - Result of the formatting operation.
    #[inline(always)]
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        match self {
            Self::EmptyInput => f.write_str(ERR_EMPTY_INPUT),
            Self::InvalidIpAddress => f.write_str(ERR_INVALID_IP_ADDRESS),
            Self::InvalidPrefixLength => f.write_str(ERR_INVALID_PREFIX_LENGTH),
            Self::InvalidSyntax => f.write_str(ERR_INVALID_SYNTAX),
            Self::NonCanonicalNetwork => f.write_str(ERR_NON_CANONICAL_NETWORK),
        }
    }
}

/// Marks `IpCidrError` as a standard error type.
impl Error for IpCidrError {}