Struct ip2location::ProxyDB

source ·
pub struct ProxyDB { /* private fields */ }

Implementations§

Loads a Ip2Proxy Database .bin file from path

Example usage
 use ip2location::DB;

 let mut db = DB::from_file("data/IP2PROXY-IP-COUNTRY.BIN").unwrap();

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

Example usage
 use ip2location::DB;

 let mut db = DB::from_file_mmap("data/IP2PROXY-IP-COUNTRY.BIN").unwrap();

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

Example usage
 use ip2location::{DB, Record};

 let mut db = DB::from_file("data/IP2PROXY-IP-COUNTRY.BIN").unwrap();
 let geo_info = db.ip_lookup("1.1.1.1".parse().unwrap()).unwrap();
 println!("{:#?}", geo_info);
 let record = if let Record::ProxyDb(rec) = geo_info {
   Some(rec)
 } else { None };
 let geo_info = record.unwrap();
 assert!(!geo_info.country.is_none());

Trait Implementations§

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.