Crate public_ip_address

source ·
Expand description

§🔎 Public IP Address Lookup and Geolocation Information

public-ip-address is a simple, easy-to-use Rust library for performing public IP lookups from various services. It provides a unified interface to fetch public IP address and geolocation information from multiple providers.

Arbitrary IP address lookup and access API keys are supported for certain providers.

The library provides an asynchronous and blocking interfaces to make it easy to integrate with other async codebase.

The library also includes caching functionality to improve performance for repeated lookups and minimaze rate-limiting. The cache file can be encrypted when enabled through the encryption feature flag for additional privacy.

§Usage

[dependencies]
public-ip-address = { version = "0.3" }

§Example

use std::error::Error;
#[cfg_attr(not(feature = "blocking"), tokio::main)]
#[maybe_async::maybe_async]
async fn main() -> Result<(), Box<dyn Error>> {
    let result = public_ip_address::perform_lookup(None).await?;
    println!("{}", result);
    Ok(())
}

§Features

  • Unified interface for multiple IP lookup providers
  • Caching of lookup results to improve performance
  • Customizable cache expiration time

For more details, please refer to the API documentation.

Modules§

  • 🗄️ Response cache Module
  • ❌ Crate errors
  • 🛠️ Lookup service provider module
  • ✉️ Lookup response.

Functions§

  • Performs a lookup with a list of specific service providers and caches the result.
  • Performs a lookup using a predefined list of LookupProviders and caches the result.
  • Performs a lookup using a list of providers until a successful response is received.