48 releases

0.24.0 Jan 10, 2024
0.23.0 Apr 3, 2022
0.22.0 Mar 23, 2022
0.21.0 Jul 20, 2021
0.1.0 Nov 22, 2014

#22 in Database interfaces

Download history 20039/week @ 2023-11-25 16880/week @ 2023-12-02 17957/week @ 2023-12-09 17822/week @ 2023-12-16 6527/week @ 2023-12-23 12827/week @ 2023-12-30 17535/week @ 2024-01-06 15503/week @ 2024-01-13 16792/week @ 2024-01-20 16740/week @ 2024-01-27 18401/week @ 2024-02-03 19978/week @ 2024-02-10 20617/week @ 2024-02-17 19584/week @ 2024-02-24 23298/week @ 2024-03-02 9098/week @ 2024-03-09

76,149 downloads per month
Used in 28 crates (26 directly)

ISC license

60KB
1.5K SLoC

Rust MaxMind DB Reader

crates.io Released API docs Master API docs

This library reads the MaxMind DB format, including the GeoIP2 and GeoLite2 databases.

Building

To build everything:

cargo build

Testing

This crate manages its test data within a git submodule. To run the tests, you will first need to run the following command.

git submodule update --init

Usage

Add this to your Cargo.toml:

[dependencies]
maxminddb = "0.17"

and this to your crate root:

extern crate maxminddb;

API Documentation

The API docs are on GitHub Pages.

Example

See examples/lookup.rs for a basic example.

Benchmarks

The projects include benchmarks using Criterion.rs.

First you need to have a working copy of the GeoIP City database. You can fetch it from here.

Place it in the root folder as GeoIP2-City.mmdb.

Once this is done, run

cargo bench

If gnuplot is installed, Criterion.rs can generate an HTML report displaying the results of the benchmark under target/criterion/report/index.html.

Result of doing 100 random IP lookups:

Contributing

Contributions welcome! Please fork the repository and open a pull request with your changes.

License

This is free software, licensed under the ISC license.

Dependencies

~0.7–1.5MB
~33K SLoC