[][src]Struct weather_util_rust::weather_forecast::WeatherForecast

pub struct WeatherForecast {
    pub list: Vec<ForecastEntry>,
    pub city: CityEntry,
}

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]

impl Debug for WeatherForecast[src]

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

impl Serialize for WeatherForecast[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<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, 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<V, T> VZip<V> for T where
    V: MultiLane<T>,