Crates.io | ip2region |
lib.rs | ip2region |
version | 0.1.0 |
source | src |
created_at | 2022-07-25 04:08:31.041325 |
updated_at | 2022-07-25 04:08:31.041325 |
description | ip2region for rust |
homepage | https://github.com/openmynet/ip2region-rs |
repository | https://github.com/openmynet/ip2region-rs |
max_upload_size | |
id | 632338 |
size | 12,074 |
ip2region 的rust非官实现版本
ip2region官方地址: https://github.com/lionsoul2014/ip2region
数据格式:xdb
格式版本:2.0
fn main(){
let searcher = ip2region::Searcher::new("./data/ip2region.xdb").unwrap();
let ip_v4 = "120.24.78.129";
let info = searcher.search(ip_v4).unwrap();
println!("{}", info)
// => `中国|0|广东省|深圳市|阿里云`
let info = searcher.std_search(ip_v4).unwrap();
println("{:?}", info)
// => `Location { contry: Some("中国"), region: None, province: Some("广东省"), city: Some("深圳市"), isp: Some("阿里云") }`
}
现已经将整个xdb加载到内存进行安全并发使用。