[−][src]Struct maxminddb::Reader
A reader for the MaxMind DB format. The lifetime 'data
is tied to the lifetime of the underlying buffer holding the contents of the database file.
Fields
metadata: Metadata
Implementations
impl<'de> Reader<Vec<u8>>
[src]
pub fn open_readfile<P: AsRef<Path>>(
database: P
) -> Result<Reader<Vec<u8>>, MaxMindDBError>
[src]
database: P
) -> Result<Reader<Vec<u8>>, MaxMindDBError>
Open a MaxMind DB database file by loading it into memory.
Example
let reader = maxminddb::Reader::open_readfile("test-data/test-data/GeoIP2-City-Test.mmdb").unwrap();
impl<'de, S: AsRef<[u8]>> Reader<S>
[src]
pub fn from_source(buf: S) -> Result<Reader<S>, MaxMindDBError>
[src]
Open a MaxMind DB database from anything that implements AsRef<u8>
Example
use std::fs; let buf = fs::read("test-data/test-data/GeoIP2-City-Test.mmdb").unwrap(); let reader = maxminddb::Reader::from_source(buf).unwrap();
pub fn lookup<T>(&'de self, address: IpAddr) -> Result<T, MaxMindDBError> where
T: Deserialize<'de>,
[src]
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_readfile("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);
Auto Trait Implementations
impl<S> RefUnwindSafe for Reader<S> where
S: RefUnwindSafe,
[src]
S: RefUnwindSafe,
impl<S> Send for Reader<S> where
S: Send,
[src]
S: Send,
impl<S> Sync for Reader<S> where
S: Sync,
[src]
S: Sync,
impl<S> Unpin for Reader<S> where
S: Unpin,
[src]
S: Unpin,
impl<S> UnwindSafe for Reader<S> where
S: UnwindSafe,
[src]
S: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,