# czdb-rs
[](https://crates.io/crates/czdb)
[](https://docs.rs/czdb)
[](https://github.com/AldenClark/czdb-rs/blob/main/LICENSE)
czdb-rs is a lightweight Rust library for querying CZDB-format IP geolocation databases. It supports both IPv4 and IPv6 lookups and provides multiple loading strategies for different performance needs.
- Buffered reader by default for low memory usage
- Optional memory-mapped file loading via the `mmap` feature
- Fully in-memory loading for fastest access
> The database file and key must be obtained from [www.cz88.net](https://cz88.net/geo-public).
## Usage
```bash
cargo add czdb
```
```rust
use czdb::Czdb;
use std::net::IpAddr;
let db = Czdb::new("path/to/your/czdb_file", "your_base64_key")?;
let ip: IpAddr = "8.8.8.8".parse().unwrap();
if let Some(location) = db.search(ip) {
println!("Location for {}: {}", ip, location);
}
# Ok::<(), Box<dyn std::error::Error>>(())
```
For the Chinese version of this document, see [README.zh.md](README.zh.md).