pub fn new(client_ip: IpAddr, client_user_agent: &str) -> Result<ClientData, Error> {
        // First, truncate the IP to a privacy safe prefix.
        let truncated_ip = truncate_ip_to_prefix(client_ip)?;
        // Lookup the geo IP data from the client IP. If no match return an error.
        let geo = geo_lookup(client_ip).ok_or_else(|| anyhow!("No geographic data available"))?;
        Ok(ClientData {
            client_ip: truncated_ip,
            client_user_agent: UserAgent::from_str(client_user_agent)?.to_string(), // Parse the User-Agent string.
            client_asn: geo.as_number(),
            client_asname: geo.as_name().to_string(),
            client_city: geo.city().to_string(),
            client_country_code: geo.country_code().to_string(),
            client_latitude: geo.latitude(),
            client_longitude: geo.longitude(),
            client_continent_code: geo.continent(),
        })
    }
/// Returns a `ClientData` using information from the downstream request.
Returns a `ClientData` using information from the downstream request.
Returns a ` ClientData ` using information from the downstream request .
pub fn new(client_ip: IpAddr, client_user_agent: &str) -> Result<ClientData, Error> {
        // First, truncate the IP to a privacy safe prefix.
        let truncated_ip = truncate_ip_to_prefix(client_ip)?;
        // Lookup the geo IP data from the client IP. If no match return an error.
        let geo = geo_lookup(client_ip).ok_or_else(|| anyhow!("No geographic data available"))?;
        Ok(ClientData {
            client_ip: truncated_ip,
            client_user_agent: UserAgent::from_str(client_user_agent)?.to_string(), // Parse the User-Agent string.
            client_asn: geo.as_number(),
            client_asname: geo.as_name().to_string(),
            client_city: geo.city().to_string(),
            client_country_code: geo.country_code().to_string(),
            client_latitude: geo.latitude(),
            client_longitude: geo.longitude(),
            client_continent_code: geo.continent(),
        })
    }
pub fn new ( client_ip : IpAddr , client_user_agent : & str ) -> Result < ClientData , Error > { // First, truncate the IP to a privacy safe prefix. let truncated_ip = truncate_ip_to_prefix ( client_ip ) ? ; // Lookup the geo IP data from the client IP. If no match return an error. let geo = geo_lookup ( client_ip ) . ok_or_else ( | | anyhow ! ( " " ) ) ? ; Ok ( ClientData { client_ip : truncated_ip , client_user_agent : UserAgent :: from_str ( client_user_agent ) ? . to_string ( ) , // Parse the User-Agent string. client_asn : geo . as_number ( ) , client_asname : geo . as_name ( ) . to_string ( ) , client_city : geo . city ( ) . to_string ( ) , client_country_code : geo . country_code ( ) . to_string ( ) , client_latitude : geo . latitude ( ) , client_longitude : geo . longitude ( ) , client_continent_code : geo . continent ( ) , } ) }
Returns a `ClientData` using information from the downstream request.
Returns a ` ClientData ` using information from the downstream request .
client_ip
IpAddr
client_user_agent
&str