mmdb-writer
Write MaxMind DB (.mmdb) files in pure, safe Rust.
Build an IP-address-to-data lookup database — the same on-disk format used by GeoIP2 /
GeoLite2 — that any MaxMind-compatible reader can consume: the
maxminddb crate, mmdbinspect, the official Go and
Python readers, and so on.
#![forbid(unsafe_code)]. The only required dependencies are
ipnet, thiserror,
and bon.
Quickstart
[]
= "0.1"
use IpNet;
use Writer;
use Serialize;
#
Read it back with the maxminddb crate to confirm:
let reader = open_readfile?;
let city: City = reader.lookup?.unwrap;
assert_eq!;
Features
| Feature | Default | Description |
|---|---|---|
serde |
✅ | Writer::insert accepts any serde::Serialize; Value is Serialize/Deserialize. |
load |
— | Writer::load reads an existing .mmdb (via maxminddb) to extend it. Implies serde. |
Disable defaults to build the value-only API with no serde dependency:
= { = "0.1", = false }
use IpNet;
use ;
#
Capabilities
- IPv4 and IPv6 databases (
ip_version4 or 6), with IPv4 automatically reachable from the IPv4-mapped, 6to4, and Teredo ranges via tree aliasing. - All MMDB data types: map, array, string, bytes, double, float, boolean, and unsigned integers up to 128-bit plus signed 32-bit.
- Insert strategies: last-write-wins replace (default), custom read-modify-write via
insert_with, and top-level / deep map merges. insert_rangefor arbitrary start–end IP ranges (decomposed into CIDR blocks).- Automatic record sizing (24 / 28 / 32-bit) and pointer-based data deduplication for compact output, with a deterministic byte layout for reproducible builds.
How this compares
maxminddb-writer is the other Rust writer; it
is minimal and low-level. mmdb-writer aims for parity with the official Go
mmdbwriter: a typed Value model, insert
strategies, IPv4/IPv6 support, reserved-network handling, and thorough documentation.
Minimum supported Rust version
The MSRV is 1.85 (required by edition 2024). Raising it is a minor-version change.
License
Licensed under either of
- Apache License, Version 2.0 (LICENSE-APACHE)
- MIT license (LICENSE-MIT)
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.