ipgeolocate 0.3.6

Get IP address geolocation information freely.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
use ipgeolocate::{Locator, Service};
use std::net::Ipv4Addr;

// Prints the city where 1.1.1.1 is.
#[tokio::main]
async fn main() {
    let service = Service::IpApi;
    let ipv4 = Ipv4Addr::new(1, 1, 1, 1);

    match Locator::get_ipv4(ipv4, service).await {
        Ok(ip) => println!("{} - {} ({})", ip.ip, ip.city, ip.country),
        Err(error) => println!("Error: {}", error),
    };
}