fn parse_cidr_block(block: &str) -> anyhow::Result<IpNetwork> {
    let cidr = block
        .parse()
        .context("WEB_PAGE_OFFSET_CIDR_BLOCKLIST must contain IPv4 or IPv6 CIDR blocks.")?;

    let host_prefix = match cidr {
        IpNetwork::V4(_) => 16,
        IpNetwork::V6(_) => 64,
    };

    if cidr.prefix() < host_prefix {
        return Err(anyhow!("WEB_PAGE_OFFSET_CIDR_BLOCKLIST only allows CIDR blocks with a host prefix of at least 16 bits (IPv4) or 64 bits (IPv6)."));
    }

    Ok(cidr)
}
/// Parses a CIDR block string to a valid `IpNetwork` struct.
///
/// The purpose is to be able to block IP ranges that overload the API that uses pagination.
///
/// The minimum number of bits for a host prefix must be
///
/// * at least 16 for IPv4 based CIDRs.
/// * at least 64 for IPv6 based CIDRs
///
Parses a CIDR block string to a valid `IpNetwork` struct.
The purpose is to be able to block IP ranges that overload the API that uses pagination.

The minimum number of bits for a host prefix must be

at least 16 for IPv4 based CIDRs.
at least 64 for IPv6 based CIDRs
Parses a CIDR block string to a valid ` IpNetwork ` struct . The purpose is to be able to block IP ranges that overload the API that uses pagination . The minimum number of bits for a host prefix must be at least 16 for IPv4 based CIDRs . at least 64 for IPv6 based CIDRs
fn parse_cidr_block(block: &str) -> anyhow::Result<IpNetwork> {
    let cidr = block
        .parse()
        .context("WEB_PAGE_OFFSET_CIDR_BLOCKLIST must contain IPv4 or IPv6 CIDR blocks.")?;
    let host_prefix = match cidr {
        IpNetwork::V4(_) => 16,
        IpNetwork::V6(_) => 64,
    };
    if cidr.prefix() < host_prefix {
        return Err(anyhow!("WEB_PAGE_OFFSET_CIDR_BLOCKLIST only allows CIDR blocks with a host prefix of at least 16 bits (IPv4) or 64 bits (IPv6)."));
    }
    Ok(cidr)
}
fn parse_cidr_block ( block : & str ) -> anyhow :: Result < IpNetwork > { let cidr = block . parse ( ) . context ( " " ) ? ; let host_prefix = match cidr { IpNetwork :: V4 ( _ ) => 16 , IpNetwork :: V6 ( _ ) => 64 , } ; if cidr . prefix ( ) < host_prefix { return Err ( anyhow ! ( " " ) ) ; } Ok ( cidr ) }
Parses a CIDR block string to a valid `IpNetwork` struct.
Parses a CIDR block string to a valid ` IpNetwork ` struct .
block
&str