ip2region_private/binding/rust/readme.md

857 B
Raw Blame History

Rust 客户端

用法

都在 src/example

另外 cargo doc --features lazy 可以看到所有 API

添加依赖

注意 # 是 toml格式的注释文件前三行的 pathgit 是引用包的方式,path 是按路径引用包,git 是按git项目地址按实际情况选一个。

[dependencies.ip2region]
git = "https://github.com/lionsoul2014/ip2region"
# git = "https://github.com/biluohc/ip2region"
# path = "../"
version = "*"
# features = ["lazy"]

代码

查看 src/example/src/main.rs

lazy feature 把 DB 直接打包进二进制

取消上面 toml 的 # features = ["lazy"] 行的注释即可使用,其 api 是 memory_search

只是目前 DB 足有3.2M,还是有些感人的。

关键的一行是 features = ["lazy"] ,不需要则可以注释或者删掉。