https://github.com/oschwald/maxminddb-rust
Rust MaxMind DB Reader
https://github.com/oschwald/maxminddb-rust
Last synced: about 1 year ago
JSON representation
Rust MaxMind DB Reader
- Host: GitHub
- URL: https://github.com/oschwald/maxminddb-rust
- Owner: oschwald
- License: isc
- Created: 2014-04-27T21:26:43.000Z (about 12 years ago)
- Default Branch: main
- Last Pushed: 2025-05-09T23:14:22.000Z (about 1 year ago)
- Last Synced: 2025-05-10T00:24:41.747Z (about 1 year ago)
- Language: Rust
- Homepage:
- Size: 8.48 MB
- Stars: 226
- Watchers: 6
- Forks: 54
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Rust MaxMind DB Reader #
[](https://crates.io/crates/maxminddb) [](http://docs.rs/maxminddb)
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.
```bash
git submodule update --init
```
## Usage ##
Add this to your `Cargo.toml`:
```toml
[dependencies]
maxminddb = "0.17"
```
and this to your crate root:
```rust
extern crate maxminddb;
```
## API Documentation ##
The API docs are on [Docs.rs](https://docs.rs/maxminddb/latest/maxminddb/struct.Reader.html).
## Example ##
See [`examples/lookup.rs`](https://github.com/oschwald/maxminddb-rust/blob/main/examples/lookup.rs) for a basic example.
## Benchmarks ##
The projects include benchmarks using [Criterion.rs](https://github.com/bheisler/criterion.rs).
First you need to have a working copy of the GeoIP City database.
You can fetch it from [here](https://dev.maxmind.com/geoip/geoip2/geolite2/).
Place it in the root folder as `GeoIP2-City.mmdb`.
Once this is done, run
```
cargo bench
```
If [gnuplot](http://www.gnuplot.info/) 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.