Crate ipinfo

Source
Expand description

§IPinfo: The rust library to lookup IP address information

This is the Rust client library for the IPinfo.io IP address API. It allows you to lookup your own IP address, or get any of the following details for an IP:

  • IP geolocation (city, region, country, postal code, latitude and longitude)
  • ASN details (ISP or network operator, associated domain name, and type, such as business, hosting or company)
  • Company details (the name and domain of the business that uses the IP address)
  • Carrier details (the name of the mobile carrier and MNC and MCC for that carrier if the IP is used exclusively for mobile traffic)

§Features

  • Smart LRU cache for cost and quota savings.
  • Structured and type checked query results.
  • Bulk IP address lookup using IPinfo batch API.

§Example

use ipinfo::{IpInfo, IpInfoConfig};
#[tokio::main]
async fn main() {
  // Setup token and other configurations.
  let config = IpInfoConfig { token: Some("my token".to_string()), ..Default::default() };

  // Setup IpInfo structure and start looking up IP addresses.
  let mut ipinfo = IpInfo::new(config).expect("should construct");
  let res = ipinfo.lookup("8.8.8.8").await;

  match res {
    Ok(r) => println!("{}: {}", "8.8.8.8", r.hostname.as_ref().unwrap()),
    Err(e) => println!("error occurred: {}", &e.to_string()),
  }
}

Macros§

err
Create a new error (of a given kind) with a formatted message

Structs§

AbuseDetails
Abuse details.
AsnDetails
ASN details.
BatchReqOpts
CONTINENTS
COUNTRIES
CURRENCIES
CarrierDetails
Mobile carrier details.
CompanyDetails
Company details.
Continent
Continent details.
CountryCurrency
CountryCurrency details.
CountryFlag
CountryFlag details.
DomainsDetails
Domains details.
EU
FLAGS
IpDetails
IP address lookup details.
IpError
The IpError type is the only error type that can be returned from this crate’s API.
IpInfo
IPinfo requests context structure.
IpInfoConfig
IpInfo structure configuration.
PrivacyDetails
Privacy details.

Enums§

IpErrorKind
An enum of errors to represent the possible kinds of IpError.

Constants§

BATCH_MAX_SIZE
BATCH_REQ_TIMEOUT_DEFAULT

Functions§

cache_key
is_bogon
Returns a boolean indicating whether an IP address is bogus.
is_bogon_addr
Returns a boolean indicating whether an IP address is bogus.