diff --git a/lib/entry/libimagentrygps/src/types.rs b/lib/entry/libimagentrygps/src/types.rs index a8da0124..265539e7 100644 --- a/lib/entry/libimagentrygps/src/types.rs +++ b/lib/entry/libimagentrygps/src/types.rs @@ -34,14 +34,14 @@ pub trait FromValue : Sized { #[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)] pub struct GPSValue { - pub degree: i32, - pub minutes: i32, - pub seconds: i32, + pub degree: i64, + pub minutes: i64, + pub seconds: i64, } impl GPSValue { - pub fn new(d: i32, m: i32, s: i32) -> GPSValue { + pub fn new(d: i64, m: i64, s: i64) -> GPSValue { GPSValue { degree: d, minutes: m, @@ -49,15 +49,15 @@ impl GPSValue { } } - pub fn degree(&self) -> i32 { + pub fn degree(&self) -> i64 { self.degree } - pub fn minutes(&self) -> i32 { + pub fn minutes(&self) -> i64 { self.minutes } - pub fn seconds(&self) -> i32 { + pub fn seconds(&self) -> i64 { self.seconds } @@ -68,9 +68,9 @@ impl Into for GPSValue { fn into(self) -> Value { let mut map = BTreeMap::new(); - let _ = map.insert("degree".to_owned(), Value::Integer(self.degree as i64)); - let _ = map.insert("minutes".to_owned(), Value::Integer(self.minutes as i64)); - let _ = map.insert("seconds".to_owned(), Value::Integer(self.seconds as i64)); + let _ = map.insert("degree".to_owned(), Value::Integer(self.degree)); + let _ = map.insert("minutes".to_owned(), Value::Integer(self.minutes)); + let _ = map.insert("seconds".to_owned(), Value::Integer(self.seconds)); Value::Table(map) } @@ -80,7 +80,7 @@ impl FromValue for GPSValue { fn from_value(v: &Value) -> Result { let int_to_appropriate_width = |v: &Value| { v.as_integer() - .ok_or(GPSE::from_kind(GPSEK::HeaderTypeError)).and_then(i64_to_i32) + .ok_or(GPSE::from_kind(GPSEK::HeaderTypeError)) }; match *v { @@ -172,12 +172,4 @@ impl Display for Coordinates { } } -/// Helper to convert a i64 to i32 or return an error if this doesn't work. -fn i64_to_i32(i: i64) -> Result { - if i > (::max_value() as i64) { - Err(GPSE::from_kind(GPSEK::NumberConversionError)) - } else { - Ok(i as i32) - } -}