[−][src]Struct ichen_openprotocol::GeoLocation
A data structure containing a single physical geo-location.
Fields
geo_latitude: f64
Latitude
geo_longitude: f64
Longitude
Methods
impl GeoLocation
[src]
pub fn new(latitude: f64, longitude: f64) -> Self
[src]
Create a new GeoLocation
.
Examples
// Notice this is an invalid geo-location position, but still works // To validate the data structure, call the `validate` method. let geo = GeoLocation::new(123.456, -987.654); assert_eq!(123.456, geo.geo_latitude); assert_eq!(-987.654, geo.geo_longitude);
pub fn validate(&self) -> Result<'static, ()>
[src]
Validate the data structure.
Errors
Returns Err(
OpenProtocolError::InvalidField
)
if either geo_latitude
or geo_longitude
is not a valid floating-point number.
Returns Err(
OpenProtocolError::ConstraintViolated
)
if geo_latitude
and geo_longitude
together does not represent a valid Geo-Location position.
Examples
let geo1 = GeoLocation::new(23.456, std::f64::NEG_INFINITY); assert_eq!( r#"Err(InvalidField { field: "geo_longitude", value: "-inf", description: "Infinity is not a supported value" })"#, format!("{:?}", geo1.validate()) ); let geo2 = GeoLocation::new(123.456, 987.654); assert_eq!( r#"Err(ConstraintViolated("latitude (123.456) must be between -90 and 90"))"#, format!("{:?}", geo2.validate()) );
Trait Implementations
impl PartialEq<GeoLocation> for GeoLocation
[src]
fn eq(&self, other: &GeoLocation) -> bool
[src]
fn ne(&self, other: &GeoLocation) -> bool
[src]
impl Debug for GeoLocation
[src]
impl Serialize for GeoLocation
[src]
fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error> where
__S: Serializer,
[src]
__S: Serializer,
impl<'de> Deserialize<'de> for GeoLocation
[src]
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
[src]
__D: Deserializer<'de>,
Auto Trait Implementations
impl Sync for GeoLocation
impl Unpin for GeoLocation
impl Send for GeoLocation
impl UnwindSafe for GeoLocation
impl RefUnwindSafe for GeoLocation
Blanket Implementations
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
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.
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>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> DeserializeOwned for T where
T: Deserialize<'de>,
[src]
T: Deserialize<'de>,