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.
- Country
Currency - CountryCurrency details.
- Country
Flag - CountryFlag details.
- Domains
Details - 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.
- IpInfo
Config - IpInfo structure configuration.
- 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.