pub struct WeatherService { /* private fields */ }Implementations§
Source§impl WeatherService
impl WeatherService
Examples found in repository?
More examples
examples/08_weather_attribution_snapshot.rs (line 9)
8fn main() -> Result<(), Box<dyn Error>> {
9 let service = WeatherService::shared();
10
11 if let Some(attribution) = support::handle_result("weather attribution", service.attribution())?
12 {
13 println!(
14 "service={} legal_page={}",
15 attribution.service_name, attribution.legal_page_url
16 );
17 }
18
19 support::finish("weather attribution");
20 Ok(())
21}examples/10_moon_events_snapshot.rs (line 9)
8fn main() -> Result<(), Box<dyn Error>> {
9 let service = WeatherService::shared();
10 let location = support::sample_location();
11
12 if let Some(moon) = support::handle_result("moon events", service.moon_events(&location))? {
13 println!(
14 "phase={:?} moonrise={:?} moonset={:?}",
15 moon.phase, moon.moonrise, moon.moonset
16 );
17 }
18
19 support::finish("moon events");
20 Ok(())
21}examples/05_weather_alerts_snapshot.rs (line 9)
8fn main() -> Result<(), Box<dyn Error>> {
9 let service = WeatherService::shared();
10 let location = support::sample_location();
11
12 if let Some(alerts) =
13 support::handle_result("weather alerts", service.weather_alerts(&location))?
14 {
15 let first_severity = alerts.first().map(WeatherAlert::severity_kind);
16 println!("alerts={} first_severity={first_severity:?}", alerts.len());
17 }
18
19 support::finish("weather alerts");
20 Ok(())
21}examples/01_weather_service_smoke.rs (line 9)
8fn main() -> Result<(), Box<dyn Error>> {
9 let service = WeatherService::shared();
10 let location = support::sample_location();
11
12 if let Some(weather) = support::handle_result("weather service", service.weather(&location))? {
13 println!(
14 "current={:.1}°C hourly={} daily={} alerts={}",
15 weather.current_weather.temperature,
16 weather.hourly_forecast.len(),
17 weather.daily_forecast.len(),
18 weather.weather_alerts.len()
19 );
20 }
21
22 support::finish("weather service");
23 Ok(())
24}examples/02_current_weather_snapshot.rs (line 9)
8fn main() -> Result<(), Box<dyn Error>> {
9 let service = WeatherService::shared();
10 let location = support::sample_location();
11
12 if let Some(current) =
13 support::handle_result("current weather", service.current_weather(&location))?
14 {
15 println!(
16 "temp={:.1}°C feels_like={:.1}°C pressure={:.1}hPa daylight={}",
17 current.temperature,
18 current.feels_like,
19 current.pressure_reading().value,
20 current.is_daylight
21 );
22 }
23
24 support::finish("current weather");
25 Ok(())
26}Additional examples can be found in:
pub const fn new() -> Self
Sourcepub fn attribution(&self) -> Result<WeatherAttribution, WeatherKitError>
pub fn attribution(&self) -> Result<WeatherAttribution, WeatherKitError>
Examples found in repository?
examples/08_weather_attribution_snapshot.rs (line 11)
8fn main() -> Result<(), Box<dyn Error>> {
9 let service = WeatherService::shared();
10
11 if let Some(attribution) = support::handle_result("weather attribution", service.attribution())?
12 {
13 println!(
14 "service={} legal_page={}",
15 attribution.service_name, attribution.legal_page_url
16 );
17 }
18
19 support::finish("weather attribution");
20 Ok(())
21}Sourcepub fn weather(&self, location: &CLLocation) -> Result<Weather, WeatherKitError>
pub fn weather(&self, location: &CLLocation) -> Result<Weather, WeatherKitError>
Examples found in repository?
examples/01_weather_service_smoke.rs (line 12)
8fn main() -> Result<(), Box<dyn Error>> {
9 let service = WeatherService::shared();
10 let location = support::sample_location();
11
12 if let Some(weather) = support::handle_result("weather service", service.weather(&location))? {
13 println!(
14 "current={:.1}°C hourly={} daily={} alerts={}",
15 weather.current_weather.temperature,
16 weather.hourly_forecast.len(),
17 weather.daily_forecast.len(),
18 weather.weather_alerts.len()
19 );
20 }
21
22 support::finish("weather service");
23 Ok(())
24}More examples
examples/01_weather_smoke.rs (line 7)
3fn main() -> Result<(), Box<dyn std::error::Error>> {
4 let service = WeatherService::shared();
5 let location = CLLocation::new(37.3349, -122.0090);
6
7 match service.weather(&location) {
8 Ok(weather) => {
9 println!(
10 "current temperature: {:.1}°C",
11 weather.current_weather.temperature
12 );
13 }
14 Err(error) if error.is_entitlement_issue() => {
15 eprintln!("weatherkit requires entitled bundle ID; check developer.apple.com/account");
16 }
17 Err(error) => return Err(error.into()),
18 }
19
20 println!("✅ weatherkit smoke (with caveats)");
21 Ok(())
22}Sourcepub fn current_weather(
&self,
location: &CLLocation,
) -> Result<CurrentWeather, WeatherKitError>
pub fn current_weather( &self, location: &CLLocation, ) -> Result<CurrentWeather, WeatherKitError>
Examples found in repository?
examples/02_current_weather_snapshot.rs (line 13)
8fn main() -> Result<(), Box<dyn Error>> {
9 let service = WeatherService::shared();
10 let location = support::sample_location();
11
12 if let Some(current) =
13 support::handle_result("current weather", service.current_weather(&location))?
14 {
15 println!(
16 "temp={:.1}°C feels_like={:.1}°C pressure={:.1}hPa daylight={}",
17 current.temperature,
18 current.feels_like,
19 current.pressure_reading().value,
20 current.is_daylight
21 );
22 }
23
24 support::finish("current weather");
25 Ok(())
26}Sourcepub fn hourly_forecast(
&self,
location: &CLLocation,
) -> Result<HourlyForecast, WeatherKitError>
pub fn hourly_forecast( &self, location: &CLLocation, ) -> Result<HourlyForecast, WeatherKitError>
Examples found in repository?
examples/04_hourly_forecast_snapshot.rs (line 13)
8fn main() -> Result<(), Box<dyn Error>> {
9 let service = WeatherService::shared();
10 let location = support::sample_location();
11
12 if let Some(hourly) =
13 support::handle_result("hourly forecast", service.hourly_forecast(&location))?
14 {
15 if let Some(first) = hourly.forecast.first() {
16 println!(
17 "first_hour={} temp={:.1}°C precip={:?} wind={:.1}m/s",
18 first.date, first.temperature, first.precipitation, first.wind.speed
19 );
20 } else {
21 println!("hourly forecast returned no hours");
22 }
23 }
24
25 support::finish("hourly forecast");
26 Ok(())
27}pub fn hourly_forecast_in( &self, location: &CLLocation, interval: DateInterval, ) -> Result<HourlyForecast, WeatherKitError>
Sourcepub fn daily_forecast(
&self,
location: &CLLocation,
) -> Result<DailyForecast, WeatherKitError>
pub fn daily_forecast( &self, location: &CLLocation, ) -> Result<DailyForecast, WeatherKitError>
Examples found in repository?
examples/03_daily_forecast_snapshot.rs (line 13)
8fn main() -> Result<(), Box<dyn Error>> {
9 let service = WeatherService::shared();
10 let location = support::sample_location();
11
12 if let Some(daily) =
13 support::handle_result("daily forecast", service.daily_forecast(&location))?
14 {
15 if let Some(first) = daily.forecast.first() {
16 println!(
17 "first_day={} high={:.1}°C low={:.1}°C sunrise={:?}",
18 first.date, first.high_temperature, first.low_temperature, first.sun.sunrise
19 );
20 } else {
21 println!("daily forecast returned no days");
22 }
23 }
24
25 support::finish("daily forecast");
26 Ok(())
27}pub fn daily_forecast_in( &self, location: &CLLocation, interval: DateInterval, ) -> Result<DailyForecast, WeatherKitError>
Sourcepub fn minute_forecast(
&self,
location: &CLLocation,
) -> Result<Option<MinuteForecastCollection>, WeatherKitError>
pub fn minute_forecast( &self, location: &CLLocation, ) -> Result<Option<MinuteForecastCollection>, WeatherKitError>
Examples found in repository?
examples/06_minute_forecast_snapshot.rs (line 13)
8fn main() -> Result<(), Box<dyn Error>> {
9 let service = WeatherService::shared();
10 let location = support::sample_location();
11
12 if let Some(minute) =
13 support::handle_result("minute forecast", service.minute_forecast(&location))?
14 {
15 if let Some(minute) = minute {
16 println!(
17 "summary={} entries={}",
18 minute.summary,
19 minute.forecast.len()
20 );
21 } else {
22 println!("minute forecast unavailable for this location");
23 }
24 }
25
26 support::finish("minute forecast");
27 Ok(())
28}Sourcepub fn weather_alerts(
&self,
location: &CLLocation,
) -> Result<Vec<WeatherAlert>, WeatherKitError>
pub fn weather_alerts( &self, location: &CLLocation, ) -> Result<Vec<WeatherAlert>, WeatherKitError>
Examples found in repository?
examples/05_weather_alerts_snapshot.rs (line 13)
8fn main() -> Result<(), Box<dyn Error>> {
9 let service = WeatherService::shared();
10 let location = support::sample_location();
11
12 if let Some(alerts) =
13 support::handle_result("weather alerts", service.weather_alerts(&location))?
14 {
15 let first_severity = alerts.first().map(WeatherAlert::severity_kind);
16 println!("alerts={} first_severity={first_severity:?}", alerts.len());
17 }
18
19 support::finish("weather alerts");
20 Ok(())
21}pub fn availability( &self, location: &CLLocation, ) -> Result<WeatherAvailability, WeatherKitError>
pub fn weather_including( &self, location: &CLLocation, query: WeatherQuery, ) -> Result<WeatherQueryResult, WeatherKitError>
pub fn weather_including2( &self, location: &CLLocation, query1: WeatherQuery, query2: WeatherQuery, ) -> Result<(WeatherQueryResult, WeatherQueryResult), WeatherKitError>
Sourcepub fn weather_including3(
&self,
location: &CLLocation,
query1: WeatherQuery,
query2: WeatherQuery,
query3: WeatherQuery,
) -> Result<(WeatherQueryResult, WeatherQueryResult, WeatherQueryResult), WeatherKitError>
pub fn weather_including3( &self, location: &CLLocation, query1: WeatherQuery, query2: WeatherQuery, query3: WeatherQuery, ) -> Result<(WeatherQueryResult, WeatherQueryResult, WeatherQueryResult), WeatherKitError>
Examples found in repository?
examples/15_weather_multi_query_snapshot.rs (lines 14-19)
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}pub fn weather_including4( &self, location: &CLLocation, query1: WeatherQuery, query2: WeatherQuery, query3: WeatherQuery, query4: WeatherQuery, ) -> Result<(WeatherQueryResult, WeatherQueryResult, WeatherQueryResult, WeatherQueryResult), WeatherKitError>
pub fn weather_including5( &self, location: &CLLocation, query1: WeatherQuery, query2: WeatherQuery, query3: WeatherQuery, query4: WeatherQuery, query5: WeatherQuery, ) -> Result<(WeatherQueryResult, WeatherQueryResult, WeatherQueryResult, WeatherQueryResult, WeatherQueryResult), WeatherKitError>
pub fn weather_including6( &self, location: &CLLocation, query1: WeatherQuery, query2: WeatherQuery, query3: WeatherQuery, query4: WeatherQuery, query5: WeatherQuery, query6: WeatherQuery, ) -> Result<(WeatherQueryResult, WeatherQueryResult, WeatherQueryResult, WeatherQueryResult, WeatherQueryResult, WeatherQueryResult), WeatherKitError>
pub fn weather_including_many<I>(
&self,
location: &CLLocation,
queries: I,
) -> Result<Vec<WeatherQueryResult>, WeatherKitError>where
I: IntoIterator<Item = WeatherQuery>,
Sourcepub fn weather_changes(
&self,
location: &CLLocation,
) -> Result<Option<WeatherChanges>, WeatherKitError>
pub fn weather_changes( &self, location: &CLLocation, ) -> Result<Option<WeatherChanges>, WeatherKitError>
Examples found in repository?
examples/13_weather_changes_snapshot.rs (line 12)
8fn main() -> Result<(), Box<dyn Error>> {
9 let service = WeatherService::shared();
10 let location = support::sample_location();
11
12 if let Some(changes) = support::handle_result("weather changes", service.weather_changes(&location))? {
13 match changes {
14 Some(changes) => println!("changes={} metadata_date={}", changes.len(), changes.metadata.date),
15 None => println!("changes=none"),
16 }
17 }
18
19 if let Some(comparisons) = support::handle_result(
20 "historical comparisons",
21 service.historical_comparisons(&location),
22 )? {
23 match comparisons {
24 Some(comparisons) => println!(
25 "historical_comparisons={} metadata_date={}",
26 comparisons.len(), comparisons.metadata.date
27 ),
28 None => println!("historical_comparisons=none"),
29 }
30 }
31
32 support::finish("weather changes");
33 Ok(())
34}Sourcepub fn historical_comparisons(
&self,
location: &CLLocation,
) -> Result<Option<HistoricalComparisons>, WeatherKitError>
pub fn historical_comparisons( &self, location: &CLLocation, ) -> Result<Option<HistoricalComparisons>, WeatherKitError>
Examples found in repository?
examples/13_weather_changes_snapshot.rs (line 21)
8fn main() -> Result<(), Box<dyn Error>> {
9 let service = WeatherService::shared();
10 let location = support::sample_location();
11
12 if let Some(changes) = support::handle_result("weather changes", service.weather_changes(&location))? {
13 match changes {
14 Some(changes) => println!("changes={} metadata_date={}", changes.len(), changes.metadata.date),
15 None => println!("changes=none"),
16 }
17 }
18
19 if let Some(comparisons) = support::handle_result(
20 "historical comparisons",
21 service.historical_comparisons(&location),
22 )? {
23 match comparisons {
24 Some(comparisons) => println!(
25 "historical_comparisons={} metadata_date={}",
26 comparisons.len(), comparisons.metadata.date
27 ),
28 None => println!("historical_comparisons=none"),
29 }
30 }
31
32 support::finish("weather changes");
33 Ok(())
34}Sourcepub fn daily_statistics(
&self,
location: &CLLocation,
query: DailyWeatherStatisticsQuery,
) -> Result<DailyWeatherStatisticsResult, WeatherKitError>
pub fn daily_statistics( &self, location: &CLLocation, query: DailyWeatherStatisticsQuery, ) -> Result<DailyWeatherStatisticsResult, WeatherKitError>
Examples found in repository?
examples/14_weather_statistics_snapshot.rs (line 21)
15fn main() -> Result<(), Box<dyn Error>> {
16 let service = WeatherService::shared();
17 let location = support::sample_location();
18
19 if let Some(result) = support::handle_result(
20 "daily statistics",
21 service.daily_statistics(&location, DailyWeatherStatisticsQuery::Temperature),
22 )? {
23 match result {
24 DailyWeatherStatisticsResult::Temperature(stats) => {
25 println!("daily_temperature_stats={}", stats.len());
26 }
27 DailyWeatherStatisticsResult::Precipitation(stats) => {
28 println!("daily_precipitation_stats={}", stats.len());
29 }
30 }
31 }
32
33 if let Some(result) = support::handle_result(
34 "daily summary",
35 service.daily_summary_in(
36 &location,
37 sample_interval(7),
38 DailyWeatherSummaryQuery::Precipitation,
39 ),
40 )? {
41 match result {
42 DailyWeatherSummaryResult::Temperature(days) => {
43 println!("daily_temperature_summary={}", days.len());
44 }
45 DailyWeatherSummaryResult::Precipitation(days) => {
46 println!("daily_precipitation_summary={}", days.len());
47 }
48 }
49 }
50
51 if let Some(hourly) = support::handle_result(
52 "hourly statistics",
53 service.hourly_statistics(&location, HourlyWeatherStatisticsQuery::Temperature),
54 )? {
55 println!("hourly_temperature_stats={}", hourly.len());
56 }
57
58 if let Some(result) = support::handle_result(
59 "monthly statistics",
60 service.monthly_statistics_in(
61 &location,
62 sample_interval(120),
63 MonthlyWeatherStatisticsQuery::Precipitation,
64 ),
65 )? {
66 match result {
67 MonthlyWeatherStatisticsResult::Temperature(stats) => {
68 println!("monthly_temperature_stats={}", stats.len());
69 }
70 MonthlyWeatherStatisticsResult::Precipitation(stats) => {
71 println!("monthly_precipitation_stats={}", stats.len());
72 }
73 }
74 }
75
76 support::finish("weather statistics");
77 Ok(())
78}pub fn daily_statistics_in( &self, location: &CLLocation, interval: DateInterval, query: DailyWeatherStatisticsQuery, ) -> Result<DailyWeatherStatisticsResult, WeatherKitError>
pub fn daily_statistics_between_days( &self, location: &CLLocation, start_day: i64, end_day: i64, query: DailyWeatherStatisticsQuery, ) -> Result<DailyWeatherStatisticsResult, WeatherKitError>
pub fn daily_summary( &self, location: &CLLocation, query: DailyWeatherSummaryQuery, ) -> Result<DailyWeatherSummaryResult, WeatherKitError>
Sourcepub fn daily_summary_in(
&self,
location: &CLLocation,
interval: DateInterval,
query: DailyWeatherSummaryQuery,
) -> Result<DailyWeatherSummaryResult, WeatherKitError>
pub fn daily_summary_in( &self, location: &CLLocation, interval: DateInterval, query: DailyWeatherSummaryQuery, ) -> Result<DailyWeatherSummaryResult, WeatherKitError>
Examples found in repository?
examples/14_weather_statistics_snapshot.rs (lines 35-39)
15fn main() -> Result<(), Box<dyn Error>> {
16 let service = WeatherService::shared();
17 let location = support::sample_location();
18
19 if let Some(result) = support::handle_result(
20 "daily statistics",
21 service.daily_statistics(&location, DailyWeatherStatisticsQuery::Temperature),
22 )? {
23 match result {
24 DailyWeatherStatisticsResult::Temperature(stats) => {
25 println!("daily_temperature_stats={}", stats.len());
26 }
27 DailyWeatherStatisticsResult::Precipitation(stats) => {
28 println!("daily_precipitation_stats={}", stats.len());
29 }
30 }
31 }
32
33 if let Some(result) = support::handle_result(
34 "daily summary",
35 service.daily_summary_in(
36 &location,
37 sample_interval(7),
38 DailyWeatherSummaryQuery::Precipitation,
39 ),
40 )? {
41 match result {
42 DailyWeatherSummaryResult::Temperature(days) => {
43 println!("daily_temperature_summary={}", days.len());
44 }
45 DailyWeatherSummaryResult::Precipitation(days) => {
46 println!("daily_precipitation_summary={}", days.len());
47 }
48 }
49 }
50
51 if let Some(hourly) = support::handle_result(
52 "hourly statistics",
53 service.hourly_statistics(&location, HourlyWeatherStatisticsQuery::Temperature),
54 )? {
55 println!("hourly_temperature_stats={}", hourly.len());
56 }
57
58 if let Some(result) = support::handle_result(
59 "monthly statistics",
60 service.monthly_statistics_in(
61 &location,
62 sample_interval(120),
63 MonthlyWeatherStatisticsQuery::Precipitation,
64 ),
65 )? {
66 match result {
67 MonthlyWeatherStatisticsResult::Temperature(stats) => {
68 println!("monthly_temperature_stats={}", stats.len());
69 }
70 MonthlyWeatherStatisticsResult::Precipitation(stats) => {
71 println!("monthly_precipitation_stats={}", stats.len());
72 }
73 }
74 }
75
76 support::finish("weather statistics");
77 Ok(())
78}Sourcepub fn hourly_statistics(
&self,
location: &CLLocation,
query: HourlyWeatherStatisticsQuery,
) -> Result<HourlyWeatherStatistics<HourTemperatureStatistics>, WeatherKitError>
pub fn hourly_statistics( &self, location: &CLLocation, query: HourlyWeatherStatisticsQuery, ) -> Result<HourlyWeatherStatistics<HourTemperatureStatistics>, WeatherKitError>
Examples found in repository?
examples/14_weather_statistics_snapshot.rs (line 53)
15fn main() -> Result<(), Box<dyn Error>> {
16 let service = WeatherService::shared();
17 let location = support::sample_location();
18
19 if let Some(result) = support::handle_result(
20 "daily statistics",
21 service.daily_statistics(&location, DailyWeatherStatisticsQuery::Temperature),
22 )? {
23 match result {
24 DailyWeatherStatisticsResult::Temperature(stats) => {
25 println!("daily_temperature_stats={}", stats.len());
26 }
27 DailyWeatherStatisticsResult::Precipitation(stats) => {
28 println!("daily_precipitation_stats={}", stats.len());
29 }
30 }
31 }
32
33 if let Some(result) = support::handle_result(
34 "daily summary",
35 service.daily_summary_in(
36 &location,
37 sample_interval(7),
38 DailyWeatherSummaryQuery::Precipitation,
39 ),
40 )? {
41 match result {
42 DailyWeatherSummaryResult::Temperature(days) => {
43 println!("daily_temperature_summary={}", days.len());
44 }
45 DailyWeatherSummaryResult::Precipitation(days) => {
46 println!("daily_precipitation_summary={}", days.len());
47 }
48 }
49 }
50
51 if let Some(hourly) = support::handle_result(
52 "hourly statistics",
53 service.hourly_statistics(&location, HourlyWeatherStatisticsQuery::Temperature),
54 )? {
55 println!("hourly_temperature_stats={}", hourly.len());
56 }
57
58 if let Some(result) = support::handle_result(
59 "monthly statistics",
60 service.monthly_statistics_in(
61 &location,
62 sample_interval(120),
63 MonthlyWeatherStatisticsQuery::Precipitation,
64 ),
65 )? {
66 match result {
67 MonthlyWeatherStatisticsResult::Temperature(stats) => {
68 println!("monthly_temperature_stats={}", stats.len());
69 }
70 MonthlyWeatherStatisticsResult::Precipitation(stats) => {
71 println!("monthly_precipitation_stats={}", stats.len());
72 }
73 }
74 }
75
76 support::finish("weather statistics");
77 Ok(())
78}pub fn hourly_statistics_in( &self, location: &CLLocation, interval: DateInterval, query: HourlyWeatherStatisticsQuery, ) -> Result<HourlyWeatherStatistics<HourTemperatureStatistics>, WeatherKitError>
pub fn hourly_statistics_between_hours( &self, location: &CLLocation, start_hour: i64, end_hour: i64, query: HourlyWeatherStatisticsQuery, ) -> Result<HourlyWeatherStatistics<HourTemperatureStatistics>, WeatherKitError>
pub fn monthly_statistics( &self, location: &CLLocation, query: MonthlyWeatherStatisticsQuery, ) -> Result<MonthlyWeatherStatisticsResult, WeatherKitError>
Sourcepub fn monthly_statistics_in(
&self,
location: &CLLocation,
interval: DateInterval,
query: MonthlyWeatherStatisticsQuery,
) -> Result<MonthlyWeatherStatisticsResult, WeatherKitError>
pub fn monthly_statistics_in( &self, location: &CLLocation, interval: DateInterval, query: MonthlyWeatherStatisticsQuery, ) -> Result<MonthlyWeatherStatisticsResult, WeatherKitError>
Examples found in repository?
examples/14_weather_statistics_snapshot.rs (lines 60-64)
15fn main() -> Result<(), Box<dyn Error>> {
16 let service = WeatherService::shared();
17 let location = support::sample_location();
18
19 if let Some(result) = support::handle_result(
20 "daily statistics",
21 service.daily_statistics(&location, DailyWeatherStatisticsQuery::Temperature),
22 )? {
23 match result {
24 DailyWeatherStatisticsResult::Temperature(stats) => {
25 println!("daily_temperature_stats={}", stats.len());
26 }
27 DailyWeatherStatisticsResult::Precipitation(stats) => {
28 println!("daily_precipitation_stats={}", stats.len());
29 }
30 }
31 }
32
33 if let Some(result) = support::handle_result(
34 "daily summary",
35 service.daily_summary_in(
36 &location,
37 sample_interval(7),
38 DailyWeatherSummaryQuery::Precipitation,
39 ),
40 )? {
41 match result {
42 DailyWeatherSummaryResult::Temperature(days) => {
43 println!("daily_temperature_summary={}", days.len());
44 }
45 DailyWeatherSummaryResult::Precipitation(days) => {
46 println!("daily_precipitation_summary={}", days.len());
47 }
48 }
49 }
50
51 if let Some(hourly) = support::handle_result(
52 "hourly statistics",
53 service.hourly_statistics(&location, HourlyWeatherStatisticsQuery::Temperature),
54 )? {
55 println!("hourly_temperature_stats={}", hourly.len());
56 }
57
58 if let Some(result) = support::handle_result(
59 "monthly statistics",
60 service.monthly_statistics_in(
61 &location,
62 sample_interval(120),
63 MonthlyWeatherStatisticsQuery::Precipitation,
64 ),
65 )? {
66 match result {
67 MonthlyWeatherStatisticsResult::Temperature(stats) => {
68 println!("monthly_temperature_stats={}", stats.len());
69 }
70 MonthlyWeatherStatisticsResult::Precipitation(stats) => {
71 println!("monthly_precipitation_stats={}", stats.len());
72 }
73 }
74 }
75
76 support::finish("weather statistics");
77 Ok(())
78}pub fn monthly_statistics_between_months( &self, location: &CLLocation, start_month: i64, end_month: i64, query: MonthlyWeatherStatisticsQuery, ) -> Result<MonthlyWeatherStatisticsResult, WeatherKitError>
Sourcepub fn sun_events(
&self,
location: &CLLocation,
) -> Result<SunEvents, WeatherKitError>
pub fn sun_events( &self, location: &CLLocation, ) -> Result<SunEvents, WeatherKitError>
Sourcepub fn moon_events(
&self,
location: &CLLocation,
) -> Result<MoonEvents, WeatherKitError>
pub fn moon_events( &self, location: &CLLocation, ) -> Result<MoonEvents, WeatherKitError>
Examples found in repository?
examples/10_moon_events_snapshot.rs (line 12)
8fn main() -> Result<(), Box<dyn Error>> {
9 let service = WeatherService::shared();
10 let location = support::sample_location();
11
12 if let Some(moon) = support::handle_result("moon events", service.moon_events(&location))? {
13 println!(
14 "phase={:?} moonrise={:?} moonset={:?}",
15 moon.phase, moon.moonrise, moon.moonset
16 );
17 }
18
19 support::finish("moon events");
20 Ok(())
21}Sourcepub fn pressure(
&self,
location: &CLLocation,
) -> Result<Pressure, WeatherKitError>
pub fn pressure( &self, location: &CLLocation, ) -> Result<Pressure, WeatherKitError>
Examples found in repository?
examples/12_pressure_catalog.rs (line 20)
8fn main() -> Result<(), Box<dyn Error>> {
9 let descriptors = PressureTrend::descriptors()?;
10 println!(
11 "pressure_trends={:?}",
12 descriptors
13 .iter()
14 .map(|d| d.raw_value.as_str())
15 .collect::<Vec<_>>()
16 );
17
18 let service = WeatherService::shared();
19 let location = support::sample_location();
20 if let Some(pressure) = support::handle_result("pressure", service.pressure(&location))? {
21 println!(
22 "current_pressure={:.1}hPa trend={:?}",
23 pressure.value, pressure.trend
24 );
25 }
26
27 support::finish("pressure");
28 Ok(())
29}Trait Implementations§
Source§impl Clone for WeatherService
impl Clone for WeatherService
Source§fn clone(&self) -> WeatherService
fn clone(&self) -> WeatherService
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for WeatherService
impl Debug for WeatherService
Source§impl Default for WeatherService
impl Default for WeatherService
Source§fn default() -> WeatherService
fn default() -> WeatherService
Returns the “default value” for a type. Read more
impl Copy for WeatherService
Auto Trait Implementations§
impl Freeze for WeatherService
impl RefUnwindSafe for WeatherService
impl Send for WeatherService
impl Sync for WeatherService
impl Unpin for WeatherService
impl UnsafeUnpin for WeatherService
impl UnwindSafe for WeatherService
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more