[][src]Struct ichen_openprotocol::GeoLocation

pub struct GeoLocation { /* fields omitted */ }

A data structure containing a single physical geo-location.

Methods

impl GeoLocation[src]

pub fn latitude(self) -> f32[src]

Get the latitude.

Examples

let geo = GeoLocation::new(12.345, -98.765)?;
assert_eq!(12.345, geo.latitude());

pub fn longitude(self) -> f32[src]

Get the longitude

Examples

let geo = GeoLocation::new(12.345, -98.765)?;
assert_eq!(-98.765, geo.longitude());

pub fn new(latitude: f32, longitude: f32) -> Result<Self, String>[src]

Create a new GeoLocation.

Errors

Returns Err(String) if either latitude or longitude is not a valid floating-point number, or when they together do not represent a valid geo-location position.

Error Examples

assert_eq!(
    Err("Infinity is not a supported value for longitude".into()),
    GeoLocation::new(23.456, std::f32::NEG_INFINITY)
);

assert_eq!(
    Err("invalid latitude: 123.456 (must be between -90 and 90)".into()),
    GeoLocation::new(123.456, 987.654)
);

Examples

let geo = GeoLocation::new(12.345, -98.765)?;
assert_eq!(12.345, geo.latitude());
assert_eq!(-98.765, geo.longitude());

Trait Implementations

impl Clone for GeoLocation[src]

impl Copy for GeoLocation[src]

impl Debug for GeoLocation[src]

impl<'de> Deserialize<'de> for GeoLocation[src]

impl Display for GeoLocation[src]

impl Eq for GeoLocation[src]

impl Hash for GeoLocation[src]

impl PartialEq<GeoLocation> for GeoLocation[src]

impl Serialize for GeoLocation[src]

impl StructuralEq for GeoLocation[src]

impl StructuralPartialEq for GeoLocation[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> DeserializeOwned for T where
    T: Deserialize<'de>, 
[src]

impl<Q, K> Equivalent<K> for Q where
    K: Borrow<Q> + ?Sized,
    Q: Eq + ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> Typeable for T where
    T: Any

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,