| Crates.io | matchy-format |
| lib.rs | matchy-format |
| version | 2.0.0 |
| created_at | 2025-12-29 07:38:55.384683+00 |
| updated_at | 2025-12-29 07:38:55.384683+00 |
| description | Binary format and MMDB builder for matchy databases (internal) |
| homepage | |
| repository | https://github.com/matchylabs/matchy |
| max_upload_size | |
| id | 2010187 |
| size | 9,969,887 |
Unified database format orchestrating IP tries, glob patterns, and literal string matching.
This crate provides the binary format for matchy databases (.mxy files), combining three routing layers into a single memory-mapped file:
.mxy File Format:
┌─────────────────────────────┐
│ IP Search Tree (binary trie)│ ← matchy-ip-trie
├─────────────────────────────┤
│ Data Section (deduplicated) │ ← matchy-data-format
├─────────────────────────────┤
│ MMDB_PATTERN separator │
├─────────────────────────────┤
│ Paraglob Section (optional) │ ← matchy-paraglob
│ - AC automaton │
│ - Pattern entries │
│ - Glob segments │
├─────────────────────────────┤
│ Literal Hash (optional) │ ← matchy-literal-hash
│ - 96-bit hash table │
│ - Pattern mappings │
├─────────────────────────────┤
│ MMDB Metadata │
└─────────────────────────────┘
use matchy_format::{MmdbBuilder, MatchMode};
use matchy_data_format::DataValue;
use std::collections::HashMap;
let mut builder = MmdbBuilder::new(MatchMode::CaseSensitive);
// Add IP entry
let mut data = HashMap::new();
data.insert("country".to_string(), DataValue::String("US".to_string()));
builder.add_entry("1.2.3.4", data)?;
// Add pattern entry
let mut data = HashMap::new();
data.insert("category".to_string(), DataValue::String("malware".to_string()));
builder.add_entry("*.evil.com", data)?;
// Build database
let db_bytes = builder.build()?;
std::fs::write("database.mxy", db_bytes)?;
The builder automatically detects entry types:
1.2.3.4, 192.168.0.0/16, 2001:db8::/32example.com (exact match only)*.example.com, file?.txt (wildcard matching)mmdb_builder.rs - High-level database buildermmdb/ - MMDB format structuresoffset_format.rs - Binary format definitionsendian.rs - Endianness handlingmmap.rs - Memory-mapped file wrappererror.rs - FormatError typematchy-ip-trie - IP address routingmatchy-paraglob - Glob pattern matchingmatchy-literal-hash - Exact string matchingmatchy-data-format - Data encoding/decodingmatchy-glob - Glob parsingmatchy-match-mode - Shared MatchMode enum