libmaxminddb-rs 0.1.0

Pure Rust MaxMind DB (MMDB) reader and writer with zero-copy borrowed decoding
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#[cfg(feature = "reader")]
fn main() {
    let data = std::fs::read("target/bench-data/GeoIP2-City-Bench.mmdb").unwrap();
    let r = libmaxminddb_rs::Reader::from_bytes(&data).unwrap();
    let md = r.metadata();
    println!(
        "node_count={} record_size={} ip_version={}",
        md.node_count, md.record_size, md.ip_version
    );
    // force prepared tree build by doing a lookup
    use std::net::IpAddr;
    let ip: IpAddr = "2001:db8::1".parse().unwrap();
    let _ = r.lookup_exists(ip);
}

#[cfg(not(feature = "reader"))]
fn main() {}