Skip to main content

country_code

Function country_code 

Source
pub fn country_code<T: IpAddress>(input: T) -> Option<&'static str>
Expand description

Looks up the ISO 3166-1 alpha-2 country code for an IP address.

Accepts a string slice, owned String, Ipv4Addr, Ipv6Addr, or IpAddr. Returns None if the address is not in any RIR delegated range, or if the input is a string that cannot be parsed as an IP address.