Releases: oschwald/maxminddb-rust
Releases · oschwald/maxminddb-rust
0.27.0
Immutable
release. Only release title and notes can be modified.
This release includes significant API changes. See UPGRADING.md
for migration guidance.
Breaking Changes
Lookup API
lookup()now returnsLookupResultinstead ofOption<T>. The new API
enables lazy decoding - data is only deserialized when explicitly requested.lookup_prefix()has been removed. Uselookup(ip)?.network()instead.
Iteration API
within()now requires a secondWithinOptionsparameter. Use
Default::default()for the previous behavior.Withiniterator now yieldsLookupResultinstead ofWithinItem<T>.
GeoIP2 Structs
- The
namesfields now use aNamesstruct instead ofBTreeMap<&str, &str>.
Access names directly via language fields (e.g.,names.english). - Nested struct fields (
city,country,location, etc.) are now
non-optional withDefault, simplifying access patterns. - Removed
is_anonymous_proxyandis_satellite_providerfromTraits.
These fields are no longer present in MaxMind databases.
Error Types
InvalidDatabaseandDecodingvariants now use structured fields instead
of a single string. Pattern matching must be updated.- New
InvalidInputvariant for user input errors (e.g., IPv6 lookup in
IPv4-only database).
Memory Mapping
Reader::open_mmapis nowunsafe. The caller must ensure the database
file is not modified or truncated while theReaderexists. This fixes a
soundness issue. Reported by paolobarbolini. GitHub #86.
Added
LookupResulttype with lazy decoding support:has_data()- Check if data exists for this IPnetwork()- Get the network containing the IPoffset()- Get data offset for caching/deduplicationdecode()- Deserialize full recorddecode_path()- Selectively decode specific fields by path
PathElementenum andpath!macro for navigating nested structures.WithinOptionsto control network iteration behavior:include_aliased_networks()- Include IPv4 via IPv6 aliasesinclude_networks_without_data()- Include networks without data recordsskip_empty_values()- Skip empty maps/arrays
networks()method for iterating over all networks in the database.verify()method for comprehensive database validation.Metadata::build_time()to convertbuild_epochtoSystemTime.PartialEqandEqimplementations forMetadataandWithinOptions.
Changed
- Error messages now include byte offsets when available.
decode_path()errors include path context showing where navigation failed.- Added recursion depth limit (512) matching libmaxminddb and Go reader.
- Serde deserializer improvements: size hints,
is_human_readable()returns
false,deserialize_ignored_any, anddeserialize_enumsupport. MaxMindDbErroris now#[non_exhaustive].
0.26.0
- BREAKING CHANGE: The
lookupandlookup_prefixmethods now return
Ok(None)orOk((None, prefix_len))respectively when an IP address is
valid but not found in the database (or has no associated data record),
instead of returning anErr(MaxMindDbError::AddressNotFoundError).
Code previously matching onAddressNotFoundErrormust be updated to
handle theOk(None)/Ok((None, prefix_len))variants. - BREAKING CHANGE: The
MaxMindDBErrorenum has been renamed
MaxMindDbErrorand variants have been renamed and refactored. For
example,IoErroris nowIo,InvalidDatabaseErroris now
InvalidDatabase,DecodingErroris nowDecoding,
InvalidNetworkErroris nowInvalidNetwork. TheMapErrorvariant has
been replaced byMmap(under themmapfeature flag). Code explicitly
matching on the old variant names must be updated. - BREAKING CHANGE:
MaxMindDbErrorno longer implementsPartialEq.
This is because underlying error types likestd::io::Error(now
wrapped by theIoandMmapvariants) do not implementPartialEq.
Code comparing errors directly using==orassert_eq!must be
updated, typically by usingmatches!or by matching on the error
kind and potentially its contents. - Refactored
MaxMindDbErrorhandling using thethiserrorcrate.
Variants likeIo,Mmap, andInvalidNetworknow directly wrap
the underlying error types (std::io::Error,ipnetwork::IpNetworkError). - Errors wrapping underlying types (
Io,Mmap,InvalidNetwork) now
correctly implementstd::error::Error::source(), allowing inspection
of the original cause. - The
Displayimplementation forMaxMindDbErrorhas been refined to
generally show only the specific error details, often including the
message from the source error, rather than prefixing with the variant
name. lookup_prefixnow returns the prefix length of the entry even when the
value is not found.- Fixed an internal bounds checking error when resolving data pointers.
The previous logic could cause a panic on a corrupt database.
0.25.0
- Serde will now skip serialization of the GeoIP2 struct fields
whenOptionis none. Pull request by Stefan Sundin. GitHub #79. SerializeandClonewere added to theMetadatastruct. Pull
request by Stefan Sundin. GitHub #80.- Added feature to use
simdutf8as a faster alternative when
unsafe-str-decodeis too risky. Pull request by Jakub Onderka.
GitHub #88. - Minor internal refactoring and performance improvements.
0.24.0
0.23.0
0.22.0
- A
withinmethod has been added to the reader to allow iterating
over all records in the database. Pull request by Ross McFarland.
Github #50. - Database structs in
maxminddb::geoip2have been updated. Most
noticeably, anEnterprisestruct has been added and themodel
module has been replaced bycityandcountrymodules. Also,
several missing fields have been added. Mmapis now re-exported for convenience. Pull request by zhuhaow.
GitHub #54.- Upgraded memmap2 dependency.