1 unstable release

0.1.0 Jul 25, 2022

#27 in #geolocation

Download history 1/week @ 2024-02-15 10/week @ 2024-02-22 9/week @ 2024-02-29 24/week @ 2024-03-07 26/week @ 2024-03-14 1/week @ 2024-03-21 21/week @ 2024-03-28

72 downloads per month

MIT license

10KB
174 lines

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

Dependencies

~0.5–1MB
~24K SLoC