maxmind-db-rust 0.4.0-x86_64-linux-musl → 0.5.0-x86_64-linux-musl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a828a17a7c839a34c1bc2a56faefbff229387754ba5c9f9ed918681dac08370f
4
- data.tar.gz: 9be96cbcad356a3ed0dd63b3a894da11c33fd3cbbf0315eec48e584481f7a99c
3
+ metadata.gz: 5e802338b0926b0b3569390005ff7bc4230143173bc1ea4dbf5ce3f9a5e9dd04
4
+ data.tar.gz: d6b93a5eff956d47daf4ca687ea479430c8f522b191cfff6ae4937318d962b78
5
5
  SHA512:
6
- metadata.gz: 5229ef74a197ee6ac61344960dbab9470071e24dbe1fc911fc32b544ad5c104465af2fd079f989e693e1bf20555c7d9ef3451aa5c486c21e909e063159906ebd
7
- data.tar.gz: 7bb775535b3a825276dca19e98f0e2cd5d883cf2eeaa6ea2de82079f9ca55d7347d69eccbf99e9121b3c707772d5903e02ffd96a6546e5a9fdfe3dd328cfbd75
6
+ metadata.gz: f9a77f7cff6be16ee203b9e8311c22fa842c11280a29949120e229e021d69c417622f3c178ad27a4430797cf1bb9fae62e013ad868dd43e1faec539d4c3d8de8
7
+ data.tar.gz: d4d8b3ad41716483176aeccedbfc8e398dfd124b09eecc5583a1806a607f812e3b9de73cbac35d6118c278665aaca1cfe8dd992c5cdbf66c0cdf97989a443618
data/CHANGELOG.md CHANGED
@@ -5,6 +5,49 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [0.5.0] - 2026-06-14
9
+
10
+ ### Added
11
+
12
+ - Added `MODE_FILE` as an official-gem compatibility alias for path-backed
13
+ memory-mapped readers.
14
+ - Added `MODE_PARAM_IS_BUFFER` for constructing readers from Ruby strings
15
+ containing database bytes.
16
+ - Added `Reader#get_path` and `Reader#get_many_path` for selective path lookups.
17
+ - Added `Reader#get_many` for batch lookups over arrays and enumerables.
18
+ - Added Enumerator return support for `Reader#each` when called without a block.
19
+ - Added `Reader#inspect` with closed state and database IP version.
20
+ - Added benchmark tooling for comparing git refs and measuring Ruby object
21
+ allocations.
22
+ - Added official gem parity tests, compatibility audit tests, bad data corpus
23
+ tests, and reader concurrency stress tests.
24
+
25
+ ### Changed
26
+
27
+ - Upgraded the `maxminddb` crate to 0.28.1.
28
+ - Improved IPv4 string lookup performance with a strict fast-path parser.
29
+ - Streamed non-array `get_many` and `get_many_path` inputs instead of
30
+ materializing enumerables.
31
+ - Cached parsed lookup paths per reader to reduce repeated path parsing.
32
+ - Simplified reader open mode parsing and centralized lookup error handling.
33
+ - Documented Rust extension safety invariants and `Send` requirements.
34
+
35
+ ### Fixed
36
+
37
+ - Fixed source gem native extension installation so `require "maxmind/db/rust"`
38
+ works after installing the source gem.
39
+ - Removed an unsafe reader iterator transmute.
40
+ - Improved invalid database error construction consistency across reader open
41
+ and iteration paths.
42
+ - Fixed dead test assertions and made adapted MaxMind tests independent of the
43
+ current working directory.
44
+
45
+ ### Security
46
+
47
+ - Pinned GitHub Actions to commit SHAs.
48
+ - Restricted workflow permissions and disabled persisted checkout credentials.
49
+ - Added a zizmor workflow and source-gem install smoke test to release checks.
50
+
8
51
  ## [0.4.0] - 2026-04-25
9
52
 
10
53
  ### Performance
data/README.md CHANGED
@@ -13,9 +13,10 @@ It keeps the API close to the official `maxmind-db` gem while adding Rust-backed
13
13
  - Rust implementation focused on fast lookups
14
14
  - API modeled after the official `maxmind-db` gem
15
15
  - Thread-safe lookups
16
- - Supports MMAP and in-memory modes
16
+ - Supports file-backed, MMAP, in-memory, and buffer-backed modes
17
17
  - Includes network iteration support
18
18
  - Accepts both `String` and `IPAddr` inputs
19
+ - Includes selective path lookup and batch lookup extensions
19
20
 
20
21
  ## Installation
21
22
 
@@ -81,6 +82,26 @@ puts "Prefix length: #{prefix_length}"
81
82
  reader.close
82
83
  ```
83
84
 
85
+ ### Selective and Batch Lookups
86
+
87
+ ```ruby
88
+ require 'maxmind/db/rust'
89
+
90
+ reader = MaxMind::DB::Rust::Reader.new('GeoIP2-City.mmdb')
91
+
92
+ # Decode one field without materializing the full record.
93
+ iso_code = reader.get_path('8.8.8.8', ['country', 'iso_code'])
94
+
95
+ # Batch full-record lookups.
96
+ ips = ['8.8.8.8', '1.1.1.1', '208.67.222.222']
97
+ records = reader.get_many(ips)
98
+
99
+ # Batch one-field lookups.
100
+ iso_codes = reader.get_many_path(ips, ['country', 'iso_code'])
101
+
102
+ reader.close
103
+ ```
104
+
84
105
  ### Using IPAddr Objects
85
106
 
86
107
  ```ruby
@@ -112,11 +133,24 @@ reader = MaxMind::DB::Rust::Reader.new(
112
133
  mode: MaxMind::DB::Rust::MODE_MMAP
113
134
  )
114
135
 
136
+ # MODE_FILE: Official-gem compatibility alias for path-backed MMAP
137
+ reader = MaxMind::DB::Rust::Reader.new(
138
+ 'GeoIP2-City.mmdb',
139
+ mode: MaxMind::DB::Rust::MODE_FILE
140
+ )
141
+
115
142
  # MODE_MEMORY: Load entire database into memory
116
143
  reader = MaxMind::DB::Rust::Reader.new(
117
144
  'GeoIP2-City.mmdb',
118
145
  mode: MaxMind::DB::Rust::MODE_MEMORY
119
146
  )
147
+
148
+ # MODE_PARAM_IS_BUFFER: Read from a String containing database bytes
149
+ buffer = File.binread('GeoIP2-City.mmdb')
150
+ reader = MaxMind::DB::Rust::Reader.new(
151
+ buffer,
152
+ mode: MaxMind::DB::Rust::MODE_PARAM_IS_BUFFER
153
+ )
120
154
  ```
121
155
 
122
156
  ### Accessing Metadata
@@ -176,15 +210,15 @@ reader.close
176
210
 
177
211
  ### `MaxMind::DB::Rust::Reader`
178
212
 
179
- #### `new(database_path, options = {})`
213
+ #### `new(database, options = {})`
180
214
 
181
215
  Create a new Reader instance.
182
216
 
183
217
  **Parameters:**
184
218
 
185
- - `database_path` (String): Path to the MaxMind DB file
219
+ - `database` (String): Path to the MaxMind DB file, or database bytes when using `:MODE_PARAM_IS_BUFFER`
186
220
  - `options` (Hash): Optional configuration
187
- - `:mode` (Symbol): One of `:MODE_AUTO`, `:MODE_MEMORY`, or `:MODE_MMAP`
221
+ - `:mode` (Symbol): One of `:MODE_AUTO`, `:MODE_FILE`, `:MODE_MEMORY`, `:MODE_MMAP`, or `:MODE_PARAM_IS_BUFFER`
188
222
 
189
223
  **Returns:** Reader instance
190
224
 
@@ -208,6 +242,17 @@ Look up an IP address in the database.
208
242
  - `ArgumentError`: If looking up IPv6 in an IPv4-only database
209
243
  - `MaxMind::DB::Rust::InvalidDatabaseError`: If the database is corrupt
210
244
 
245
+ #### `get_path(ip_address, path)`
246
+
247
+ Look up an IP address and return only the value at `path`.
248
+
249
+ **Parameters:**
250
+
251
+ - `ip_address` (String or IPAddr): The IP address to look up
252
+ - `path` (Array): String map keys and Integer array indexes. Negative indexes count from the end.
253
+
254
+ **Returns:** The value at the path, or `nil` if the record or path is not found
255
+
211
256
  #### `get_with_prefix_length(ip_address)`
212
257
 
213
258
  Look up an IP address and return the prefix length.
@@ -218,6 +263,27 @@ Look up an IP address and return the prefix length.
218
263
 
219
264
  **Returns:** Array `[record, prefix_length]` where record is a Hash or `nil`
220
265
 
266
+ #### `get_many(ip_addresses)`
267
+
268
+ Look up multiple IP addresses.
269
+
270
+ **Parameters:**
271
+
272
+ - `ip_addresses` (Array or Enumerable): IP address strings or IPAddr objects
273
+
274
+ **Returns:** Array of record values in input order
275
+
276
+ #### `get_many_path(ip_addresses, path)`
277
+
278
+ Look up one path for multiple IP addresses.
279
+
280
+ **Parameters:**
281
+
282
+ - `ip_addresses` (Array or Enumerable): IP address strings or IPAddr objects
283
+ - `path` (Array): String map keys and Integer array indexes
284
+
285
+ **Returns:** Array of path values in input order
286
+
221
287
  #### `metadata()`
222
288
 
223
289
  Get metadata about the database.
@@ -269,8 +335,10 @@ Metadata attributes:
269
335
  ### Constants
270
336
 
271
337
  - `MaxMind::DB::Rust::MODE_AUTO` - Automatically choose the best mode (uses MMAP)
338
+ - `MaxMind::DB::Rust::MODE_FILE` - Official-gem compatibility alias for path-backed MMAP
272
339
  - `MaxMind::DB::Rust::MODE_MEMORY` - Load entire database into memory
273
340
  - `MaxMind::DB::Rust::MODE_MMAP` - Use memory-mapped file I/O (recommended)
341
+ - `MaxMind::DB::Rust::MODE_PARAM_IS_BUFFER` - Read database bytes from a Ruby String
274
342
 
275
343
  ### Exceptions
276
344
 
@@ -278,26 +346,26 @@ Metadata attributes:
278
346
 
279
347
  ## Comparison with Official Gem
280
348
 
281
- | Feature | maxmind-db (official) | maxmind-db-rust (this gem) |
282
- | ---------------- | --------------------- | ------------------------------------------ |
283
- | Implementation | Pure Ruby | Rust with Ruby bindings |
284
- | Performance | Baseline | Faster lookup throughput in our benchmarks |
285
- | API | MaxMind::DB | MaxMind::DB::Rust |
286
- | MODE_FILE | ✓ | |
287
- | MODE_MEMORY | ✓ | ✓ |
288
- | MODE_AUTO | ✓ | ✓ |
289
- | MODE_MMAP | | ✓ |
290
- | Iterator support | ✗ | ✓ |
291
- | Thread-safe | | ✓ |
349
+ | Feature | maxmind-db (official) | maxmind-db-rust (this gem) |
350
+ | -------------------- | --------------------- | ------------------------------------------ |
351
+ | Implementation | Pure Ruby | Rust with Ruby bindings |
352
+ | Performance | Baseline | Faster lookup throughput in our benchmarks |
353
+ | API | MaxMind::DB | MaxMind::DB::Rust |
354
+ | MODE_FILE | ✓ | |
355
+ | MODE_MEMORY | ✓ | ✓ |
356
+ | MODE_AUTO | ✓ | ✓ |
357
+ | MODE_PARAM_IS_BUFFER | | ✓ |
358
+ | MODE_MMAP | ✗ | ✓ |
359
+ | Iterator support | | ✓ |
360
+ | Thread-safe | ✓ | ✓ |
292
361
 
293
362
  ## Performance
294
363
 
295
364
  Lookup performance depends on hardware, Ruby version, database, and workload.
296
365
 
297
366
  - In this project’s random-lookup benchmarks, this gem is consistently faster than the official Ruby implementation.
298
- - On `/var/lib/GeoIP/GeoIP2-City.mmdb` in this environment, random lookup throughput was about `47x` higher than the official gem.
299
367
  - `MODE_MMAP` and `MODE_MEMORY` both perform well; which is faster can vary by environment.
300
- - For reproducible numbers on your own data, run `benchmark/compare_lookups.rb` against your database.
368
+ - For current, reproducible numbers on your own data and Ruby version, run `benchmark/compare_lookups.rb` against your database.
301
369
  - Safe for concurrent lookups across threads.
302
370
 
303
371
  ## Development
@@ -10,7 +10,7 @@ module MaxMind
10
10
  # - Reader class
11
11
  # - Metadata class
12
12
  # - InvalidDatabaseError exception
13
- # - MODE_AUTO, MODE_MEMORY, MODE_MMAP constants
13
+ # - MODE_AUTO, MODE_FILE, MODE_MEMORY, MODE_MMAP, MODE_PARAM_IS_BUFFER constants
14
14
  end
15
15
  end
16
16
  end
Binary file
Binary file
Binary file
Binary file
@@ -66,7 +66,7 @@ module MaxMind
66
66
  # - Reader class
67
67
  # - Metadata class
68
68
  # - InvalidDatabaseError exception
69
- # - MODE_AUTO, MODE_MEMORY, MODE_MMAP constants
69
+ # - MODE_AUTO, MODE_FILE, MODE_MEMORY, MODE_MMAP, MODE_PARAM_IS_BUFFER constants
70
70
  end
71
71
  else
72
72
  # Official gem not loaded - define DB as a module
@@ -128,7 +128,7 @@ module MaxMind
128
128
  # - Reader class
129
129
  # - Metadata class
130
130
  # - InvalidDatabaseError exception
131
- # - MODE_AUTO, MODE_MEMORY, MODE_MMAP constants
131
+ # - MODE_AUTO, MODE_FILE, MODE_MEMORY, MODE_MMAP, MODE_PARAM_IS_BUFFER constants
132
132
  end
133
133
  end
134
134
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: maxmind-db-rust
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: x86_64-linux-musl
6
6
  authors:
7
7
  - Gregory Oschwald
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-04-25 00:00:00.000000000 Z
11
+ date: 2026-06-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest