pub struct Geo { /* private fields */ }Expand description
The geographic data associated with a particular IP address.
Implementations§
Source§impl Geo
impl Geo
Sourcepub fn as_name(&self) -> &str
pub fn as_name(&self) -> &str
The name of the organization associated with as_number.
For example, fastly is the value given for IP addresses under AS-54113.
Sourcepub fn as_number(&self) -> u32
pub fn as_number(&self) -> u32
Autonomous system (AS) number.
Sourcepub fn area_code(&self) -> u16
pub fn area_code(&self) -> u16
The telephone area code associated with an IP address.
These are only available for IP addresses in the United States, its territories, and Canada.
Sourcepub fn conn_speed(&self) -> ConnSpeed
pub fn conn_speed(&self) -> ConnSpeed
Connection speed.
Sourcepub fn country_code(&self) -> &str
pub fn country_code(&self) -> &str
A two-character ISO 3166-1 country code for the country associated with an IP address.
The US country code is returned for IP addresses associated with overseas United States military bases.
These values include subdivisions that are assigned their own country codes in ISO 3166-1. For example, subdivisions NO-21 and NO-22 are presented with the country code SJ for Svalbard and the Jan Mayen Islands.
Sourcepub fn country_code3(&self) -> &str
pub fn country_code3(&self) -> &str
A three-character ISO 3166-1 alpha-3 country code for the country associated with the IP address.
The USA country code is returned for IP addresses associated with overseas United States military bases.
Sourcepub fn country_name(&self) -> &str
pub fn country_name(&self) -> &str
Country name.
This field is the ISO 3166-1 English short name for a country.
Sourcepub fn latitude(&self) -> f64
pub fn latitude(&self) -> f64
Latitude, in units of degrees from the equator.
Values range from -90.0 to +90.0 inclusive, and are based on the WGS 84 coordinate reference system.
Sourcepub fn longitude(&self) -> f64
pub fn longitude(&self) -> f64
Longitude, in units of degrees from the IERS Reference Meridian.
Values range from -180.0 to +180.0 inclusive, and are based on the WGS 84 coordinate reference system.
Sourcepub fn metro_code(&self) -> i64
pub fn metro_code(&self) -> i64
Metro code, representing designated market areas (DMAs) in the United States.
Sourcepub fn postal_code(&self) -> &str
pub fn postal_code(&self) -> &str
The postal code associated with the IP address.
These are available for some IP addresses in Australia, Canada, France, Germany, Italy, Spain, Switzerland, the United Kingdom, and the United States.
For Canadian postal codes, this is the first 3 characters. For the United Kingdom, this is the first 2-4 characters (outward code). For countries with alphanumeric postal codes, this field is a lowercase transliteration.
Sourcepub fn proxy_description(&self) -> ProxyDescription
pub fn proxy_description(&self) -> ProxyDescription
Client proxy description.
Sourcepub fn proxy_type(&self) -> ProxyType
pub fn proxy_type(&self) -> ProxyType
Client proxy type.
Sourcepub fn region(&self) -> Option<&str>
pub fn region(&self) -> Option<&str>
ISO 3166-2 country subdivision code.
For countries with multiple levels of subdivision (for example, nations within the United Kingdom), this variable gives the more specific subdivision.
This field can be None for countries that do not have ISO country subdivision codes. For
example, None is given for IP addresses assigned to the Åland Islands (country code AX,
illustrated below).
§Examples
Region values are the subdivision part only. For typical use, a subdivision is normally formatted with its associated country code. The following example illustrates constructing an ISO 3166-2 two-part country and subdivision code from the respective fields:
let code = if let Some(region) = geo.region() {
format!("{}-{}", geo.country_code(), region)
} else {
format!("{}", geo.country_code())
};code | Region Name | Country | ISO 3166-2 subdivision |
|---|---|---|---|
AX | Ödkarby | Åland Islands | (none) |
DE-BE | Berlin | Germany | Land (State) |
GB-BNH | Brighton and Hove | United Kingdom | Unitary authority |
JP-13 | 東京都 (Tōkyō-to) | Japan | Prefecture |
RU-MOW | Москва́ (Moscow) | Russian Federation | Federal city |
SE-AB | Stockholms län | Sweden | Län (County) |
US-CA | California | United States | State |
Sourcepub fn utc_offset(&self) -> Option<UtcOffset>
pub fn utc_offset(&self) -> Option<UtcOffset>
Time zone offset from coordinated universal time (UTC) for city.
This is represented using the UtcOffset type from the time library. See
time’s documentation for more details on how to format this type or use it in time
calculations.
Returns None if the geolocation database does not have a time zone offset for this IP
address.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Geo
impl RefUnwindSafe for Geo
impl Send for Geo
impl Sync for Geo
impl Unpin for Geo
impl UnsafeUnpin for Geo
impl UnwindSafe for Geo
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
impl<T> ErasedDestructor for Twhere
T: 'static,
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