Skip to main content

15_weather_multi_query_snapshot/
15_weather_multi_query_snapshot.rs

1#[path = "support/mod.rs"]
2mod support;
3
4use std::error::Error;
5
6use weatherkit::prelude::*;
7
8fn main() -> Result<(), Box<dyn Error>> {
9    let service = WeatherService::shared();
10    let location = support::sample_location();
11
12    if let Some((current, daily, changes)) = support::handle_result(
13        "weather multi query",
14        service.weather_including3(
15            &location,
16            WeatherQuery::Current,
17            WeatherQuery::Daily,
18            WeatherQuery::Changes,
19        ),
20    )? {
21        if let WeatherQueryResult::CurrentWeather(current) = current {
22            println!("multi_query_current_temperature={:.1}", current.temperature);
23        }
24        if let WeatherQueryResult::DailyForecast(daily) = daily {
25            println!("multi_query_daily_days={}", daily.len());
26        }
27        if let WeatherQueryResult::WeatherChanges(changes) = changes {
28            println!("multi_query_changes_present={}", changes.is_some());
29        }
30    }
31
32    support::finish("weather multi query");
33    Ok(())
34}