Type Definition maxminddb::OwnedReader
source · pub type OwnedReader<'data> = OwnedReaderFile<'data>;
Expand description
A type definition substituting OwnedReader<'data>
with OwnedReaderFile<'data>
, used if the feature mmap
is not active.
Methods from Deref<Target = Reader<'data>>§
sourcepub fn lookup<T>(&self, address: IpAddr) -> Result<T, MaxMindDBError>where
T: Deserialize<'de>,
pub fn lookup<T>(&self, address: IpAddr) -> Result<T, MaxMindDBError>where
T: Deserialize<'de>,
Lookup the socket address in the opened MaxMind DB
Example:
use maxminddb::geoip2;
use std::net::IpAddr;
use std::str::FromStr;
let reader = maxminddb::Reader::open("test-data/test-data/GeoIP2-City-Test.mmdb").unwrap();
let ip: IpAddr = FromStr::from_str("89.160.20.128").unwrap();
let city: geoip2::City = reader.lookup(ip).unwrap();
print!("{:?}", city);