ip2location-ip2location

Crates.ioip2location-ip2location
lib.rsip2location-ip2location
version0.4.0
sourcesrc
created_at2022-04-06 06:19:39.218463
updated_at2023-01-30 13:45:28.443157
descriptionIP2Location™ IP Address Geolocation Database
homepagehttps://github.com/bk-rs/ip2location-rs
repositoryhttps://github.com/bk-rs/ip2location-rs
max_upload_size
id562958
size40,392
vkill (vkill)

documentation

https://docs.rs/ip2location-ip2location

README

ip2location-ip2location

Example

#[cfg(feature = "tokio_fs")]
{
use std::{net::Ipv4Addr};

use ip2location_ip2location::bin_format::{Database, TokioFile};

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let runtime = tokio::runtime::Runtime::new().unwrap();

    runtime.block_on(async move {
        let db = Database::<TokioFile>::new("/path/IP2LOCATION-LITE-DB11.BIN", 2).await?;

        if let Some(record) = db.lookup_ipv4(Ipv4Addr::new(8, 8, 8, 8), None).await? {
            assert_eq!(record.country_code.to_string(), "US");
        }

        Ok(())
    })
}
}
Commit count: 84

cargo fmt