[][src]Struct ip2location::DB

pub struct DB { /* fields omitted */ }

Implementations

impl DB[src]

pub fn from_file<P: AsRef<Path>>(path: P) -> Result<Self, Error>[src]

Loads a Ip2Location Database .bin file from path

Example usage

 use ip2location::DB;

 fn main () {
     let mut db = DB::from_file("data/IP2LOCATION-LITE-DB1.BIN").unwrap();
 }

pub fn from_file_mmap<P: AsRef<Path>>(path: P) -> Result<Self, Error>[src]

Loads a Ip2Location Database .bin file from path using mmap (memap) feature.

Example usage

 use ip2location::DB;

 fn main () {
     let mut db = DB::from_file_mmap("data/IP2LOCATION-LITE-DB1.BIN").unwrap();
 }

pub fn print_db_info(&self)[src]

Prints the DB Information to console

Example usage

use ip2location::DB;

fn main () {
    let mut db = DB::from_file_mmap("data/IP2LOCATION-LITE-DB1.BIN").unwrap();
    db.print_db_info();
}

pub fn ip_lookup(&mut self, ip: &str) -> Result<Record, Error>[src]

Lookup for the given IPv4 or IPv6 and returns the Geo information

Example usage

 use ip2location::DB;

 fn main () {
     let mut db = DB::from_file("data/IP2LOCATION-LITE-DB1.IPV6.BIN").unwrap();
     let geo_info = db.ip_lookup("2a01:cb08:8d14::").unwrap();
     println!("{:#?}", geo_info);
     assert!(!geo_info.country.is_none());
     assert_eq!(geo_info.country.unwrap().short_name, "FR")
 }

Trait Implementations

impl Debug for DB[src]

Auto Trait Implementations

impl RefUnwindSafe for DB[src]

impl Send for DB[src]

impl Sync for DB[src]

impl Unpin for DB[src]

impl UnwindSafe for DB[src]

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.