[−][src]Struct weather_util_rust::weather_forecast::WeatherForecast
Fields
list: Vec<ForecastEntry>
city: CityEntry
Methods
impl WeatherForecast
[src]
pub fn get_high_low(&self) -> BTreeMap<NaiveDate, (Temperature, Temperature)>
[src]
Get Map of Date to High/Low temperatures
use weather_util_rust::weather_forecast::WeatherForecast; use weather_util_rust::temperature::Temperature; let data: WeatherForecast = serde_json::from_str(&buf)?; let high_low = data.get_high_low(); assert_eq!(high_low.len(), 6); let date: NaiveDate = "2020-01-21".parse()?; assert_eq!( high_low.get(&date), Some( &( Temperature::try_from(272.65)?, Temperature::try_from(266.76)? ) ) );
pub fn get_forecast<T: Write>(&self, buf: &mut T) -> Result<(), Error>
[src]
Get High and Low Temperatures for the Next Few Days
use weather_util_rust::weather_forecast::WeatherForecast; let data: WeatherForecast = serde_json::from_str(&buf)?; let mut buf = Vec::new(); data.get_forecast(&mut buf)?; let buf = String::from_utf8(buf)?; assert!(buf.starts_with("\nForecast:"), buf); assert!(buf.contains("2020-01-23 High: 37.72 F / 3.18 C")); assert!(buf.contains("Low: 30.07 F / -1.07 C"));
Trait Implementations
impl Clone for WeatherForecast
[src]
fn clone(&self) -> WeatherForecast
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Debug for WeatherForecast
[src]
impl<'de> Deserialize<'de> for WeatherForecast
[src]
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
[src]
__D: Deserializer<'de>,
impl Serialize for WeatherForecast
[src]
Auto Trait Implementations
impl RefUnwindSafe for WeatherForecast
impl Send for WeatherForecast
impl Sync for WeatherForecast
impl Unpin for WeatherForecast
impl UnwindSafe for WeatherForecast
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
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> DeserializeOwned for T where
T: Deserialize<'de>,
[src]
T: Deserialize<'de>,
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut 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<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,