#[cfg(feature = "download")]
use std::net::IpAddr;
#[cfg(feature = "download")]
fn main() -> Result<(), Box<dyn std::error::Error>> {
let cache_path = "cache/ripe-data.txt";
let bytes = eu_geoip::GeoIpDb::update_cache(cache_path)?;
println!("Downloaded {bytes} bytes into {cache_path}");
let db = eu_geoip::GeoIpDb::from_ripe_delegated_file(cache_path)?;
let ip: IpAddr = "88.198.0.1".parse()?; if let Some(info) = db.lookup(ip) {
println!("{ip} -> country={}, is_eu={}", info.country_code_str(), info.is_eu);
} else {
println!("{ip} not found");
}
Ok(())
}
#[cfg(not(feature = "download"))]
fn main() {
eprintln!("This demo requires the `download` feature.");
eprintln!("Run: cargo run --features download --bin ripe_update_demo");
}