pub struct IpData { /* private fields */ }Implementations§
Source§impl IpData
impl IpData
Sourcepub fn ip(&self) -> Result<IpAddr, AddrParseError>
pub fn ip(&self) -> Result<IpAddr, AddrParseError>
Returns the IP address that was looked up.
Sourcepub fn is_eu(&self) -> bool
pub fn is_eu(&self) -> bool
Returns true or false depending on whether the country is a recognized member of the European Union. The list of all EU countries is compiled from the European Union website: https://europa.eu/european-union/about-eu/countries_en.
Sourcepub fn region(&self) -> &String
pub fn region(&self) -> &String
Returns the name of the region where the IP address is located.
Sourcepub fn region_code(&self) -> &String
pub fn region_code(&self) -> &String
Returns the ISO 3166-2 region code for the IP address.
Sourcepub fn country_name(&self) -> &String
pub fn country_name(&self) -> &String
Returns the country name where the IP address is located.
Sourcepub fn country_code(&self) -> &String
pub fn country_code(&self) -> &String
Returns the 2 letter ISO 3166-1 alpha-2 code for the country where the IP address is located.
Sourcepub fn continent_name(&self) -> &String
pub fn continent_name(&self) -> &String
Returns the name of the continent where the IP Address is located. One of Africa, Antarctica, Asia, Europe, North America, Oceania, South America.
Sourcepub fn latitude(&self) -> f64
pub fn latitude(&self) -> f64
Returns an approximate latitudinal location for the IP Address. Often near the center of population.
Examples found in repository?
5fn main() {
6 let ip = net::Ipv4Addr::new(1,1,1,1);
7 let resp = ipdata::lookup(net::IpAddr::V4(ip));
8
9 match resp {
10 Ok(resp) => {
11 println!("{}: {}, {}",
12 resp.organization(),
13 resp.latitude(), resp.longitude());
14 }
15 Err(err) => {
16 eprintln!("error: {}", err);
17 ::std::process::exit(1);
18 }
19 }
20}Sourcepub fn longitude(&self) -> f64
pub fn longitude(&self) -> f64
Returns an approximate longitudinal location for the IP Address. Often near the center of population.
Examples found in repository?
5fn main() {
6 let ip = net::Ipv4Addr::new(1,1,1,1);
7 let resp = ipdata::lookup(net::IpAddr::V4(ip));
8
9 match resp {
10 Ok(resp) => {
11 println!("{}: {}, {}",
12 resp.organization(),
13 resp.latitude(), resp.longitude());
14 }
15 Err(err) => {
16 eprintln!("error: {}", err);
17 ::std::process::exit(1);
18 }
19 }
20}Sourcepub fn asn(&self) -> &String
pub fn asn(&self) -> &String
Returns the Autonomous System Number that references the IP Address’s owning organization.
Sourcepub fn organization(&self) -> &String
pub fn organization(&self) -> &String
Returns the name of the Organisation that owns the IP Address. This will default to the ISP name if the organisation is not available.
Examples found in repository?
5fn main() {
6 let ip = net::Ipv4Addr::new(1,1,1,1);
7 let resp = ipdata::lookup(net::IpAddr::V4(ip));
8
9 match resp {
10 Ok(resp) => {
11 println!("{}: {}, {}",
12 resp.organization(),
13 resp.latitude(), resp.longitude());
14 }
15 Err(err) => {
16 eprintln!("error: {}", err);
17 ::std::process::exit(1);
18 }
19 }
20}Sourcepub fn calling_code(&self) -> &String
pub fn calling_code(&self) -> &String
Returns the international calling code where the IP adress is located.
Sourcepub fn flag(&self) -> &String
pub fn flag(&self) -> &String
Returns a URL to a PNG image with the flag of the country where the IP address is located.
Sourcepub fn emoji_flag(&self) -> &String
pub fn emoji_flag(&self) -> &String
Returns an emoji version of the flag of the country where the IP address is located.
Sourcepub fn emoji_unicode(&self) -> &String
pub fn emoji_unicode(&self) -> &String
Returns the country flag emoji in unicode.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for IpData
impl<'de> Deserialize<'de> for IpData
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for IpData
impl RefUnwindSafe for IpData
impl Send for IpData
impl Sync for IpData
impl Unpin for IpData
impl UnwindSafe for IpData
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more