Struct fastly::geo::Geo

source ·
pub struct Geo { /* private fields */ }
Expand description

The geographic data associated with a particular IP address.

Implementations§

source§

impl Geo

source

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.

source

pub fn as_number(&self) -> u32

Autonomous system (AS) number.

source

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.

source

pub fn city(&self) -> &str

City or town name.

source

pub fn conn_speed(&self) -> ConnSpeed

Connection speed.

source

pub fn conn_type(&self) -> ConnType

Connection type.

source

pub fn continent(&self) -> Continent

Continent.

source

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.

source

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.

source

pub fn country_name(&self) -> &str

Country name.

This field is the ISO 3166-1 English short name for a country.

source

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.

source

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.

source

pub fn metro_code(&self) -> i64

Metro code, representing designated market areas (DMAs) in the United States.

source

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.

source

pub fn proxy_description(&self) -> ProxyDescription

Client proxy description.

source

pub fn proxy_type(&self) -> ProxyType

Client proxy type.

source

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());
};
codeRegion NameCountryISO 3166-2 subdivision
AXÖdkarbyÅland Islands(none)
DE-BEBerlinGermanyLand (State)
GB-BNHBrighton and HoveUnited KingdomUnitary authority
JP-13東京都 (Tōkyō-to)JapanPrefecture
RU-MOWМосква́ (Moscow)Russian FederationFederal city
SE-ABStockholms länSwedenLän (County)
US-CACaliforniaUnited StatesState
source

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§

source§

impl Clone for Geo

source§

fn clone(&self) -> Geo

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Geo

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl RefUnwindSafe for Geo

§

impl Send for Geo

§

impl Sync for Geo

§

impl Unpin for Geo

§

impl UnwindSafe for Geo

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

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

source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.