ip2region

Crates.ioip2region
lib.rsip2region
version0.1.0
sourcesrc
created_at2022-07-25 04:08:31.041325
updated_at2022-07-25 04:08:31.041325
descriptionip2region for rust
homepagehttps://github.com/openmynet/ip2region-rs
repositoryhttps://github.com/openmynet/ip2region-rs
max_upload_size
id632338
size12,074
Chizard (openmynet)

documentation

https://docs.rs/ip2region

README

ip2region-rs

ip2region 的rust非官实现版本

ip2region官方地址: https://github.com/lionsoul2014/ip2region


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加载到内存进行安全并发使用。

Commit count: 7

cargo fmt