[−][src]Struct ip2location::DB
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
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]
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>,