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§
- Abuse
Details - Abuse details.
- AsnDetails
- ASN details.
- Batch
ReqOpts - CONTINENTS
- COUNTRIES
- CURRENCIES
- Carrier
Details - Mobile carrier details.
- Company
Details - Company details.
- Continent
- Continent details.
- CoreAS
- Core API AS details.
- CoreGeo
- Core API Geo details.
- Country
Currency - CountryCurrency details.
- Country
Flag - CountryFlag details.
- Domains
Details - Domains details.
- EU
- FLAGS
- IpDetails
- IP address lookup details.
- IpDetails
Core - Core API IP address lookup details.
- IpDetails
Lite - IpDetails
Plus - Plus API 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.
- IpInfo
Config - IpInfo structure configuration.
- IpInfo
Core - IpInfoCore requests context structure.
- IpInfo
Core Config - IpInfoCore structure configuration.
- IpInfo
Lite - IpInfoLite requests context structure.
- IpInfo
Lite Config - IpInfoLite structure configuration.
- IpInfo
Plus - IpInfoPlus requests context structure.
- IpInfo
Plus Config - IpInfoPlus structure configuration.
- PlusAS
- Plus API AS details (extends Core).
- Plus
Abuse - Plus API Abuse details (reuse existing AbuseDetails but with country_name).
- Plus
Anonymous - Plus API Anonymous details.
- Plus
Company - Plus API Company details (reuse existing CompanyDetails).
- Plus
Domains - Plus API Domains details (reuse existing DomainsDetails).
- PlusGeo
- Plus API Geo details (extends Core).
- Plus
Mobile - Plus API Mobile details.
- Plus
Privacy - Plus API Privacy details (reuse existing PrivacyDetails).
- Privacy
Details - Privacy details.
Enums§
- IpError
Kind - An enum of errors to represent the possible kinds of
IpError.
Constants§
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.