Skip to main content

validate_asn

Function validate_asn 

Source
pub fn validate_asn(asn: u32) -> Result<(), ProxyError>
Expand description

Returns Ok(()) when asn is a valid public Autonomous System Number, otherwise an crate::error::ProxyError::InvalidGeoMetadata describing the failure.

A “public” AS number is 1..=u32::MAX - 10 is reserved by IANA and u32::MAX is the RFC-defined “private use / reserved” placeholder, neither of which is meaningful on the wire.

§Example

use stygian_proxy::types::validate_asn;
assert!(validate_asn(13_335).is_ok());
assert!(validate_asn(0).is_err());
assert!(validate_asn(u32::MAX).is_err());