Skip to main content

Crate ip2location

Crate ip2location 

Source
Expand description

IP2Location / IP2Proxy BIN database reader.

Provides zero-copy, memory-mapped lookups against IP2Location and IP2Proxy BIN databases.

§Quick start

use ip2location::{DB, Record};

let db = DB::from_file("data/IP2LOCATION-LITE-DB1.BIN").unwrap();
let record = db.ip_lookup("8.8.8.8".parse().unwrap()).unwrap();
println!("{:#?}", record);

The database file is memory-mapped at open time and string fields in returned records borrow directly from the mapped region (Cow::Borrowed), avoiding heap allocation on the hot path.

Modules§

error
Error types returned by database operations.

Structs§

LocationDB
An opened IP2Location geolocation BIN database.
LocationRecord
Geolocation record returned by an IP2Location database lookup.
ProxyDB
An opened IP2Proxy proxy-detection BIN database.
ProxyRecord
Proxy detection record returned by an IP2Proxy database lookup.

Enums§

DB
A loaded IP2Location or IP2Proxy database.
Proxy
Proxy classification for an IP address.
Record
A lookup result from either database type.