Available on crate feature
async only.Expand description
Async API for WeatherKit — executor-agnostic Future wrappers.
Enabled with the async Cargo feature. Every Apple async throws surface
on WeatherService gets a corresponding Future
newtype here. The pattern follows the doom-fish gold standard from
screencapturekit-rs: a @_cdecl Swift thunk launches a Swift Task,
fires a C callback on completion, and the Rust side wraps the call in an
AsyncCompletionFuture via doom_fish_utils::completion::AsyncCompletion.
§Available Future types
| Future type | Swift API |
|---|---|
WeatherFuture | WeatherService.weather(for:) |
CurrentWeatherFuture | WeatherService.weather(for: including: .current) |
HourlyForecastFuture | WeatherService.weather(for: including: .hourly) |
DailyForecastFuture | WeatherService.weather(for: including: .daily) |
MinuteForecastFuture | WeatherService.weather(for: including: .minute) |
WeatherAlertsFuture | WeatherService.weather(for: including: .alerts) |
AvailabilityFuture | WeatherService.weather(for: including: .availability) |
AttributionFuture | WeatherService.attribution |
WeatherChangesFuture | WeatherService.weather(for: including: .changes) (macOS 15+) |
HistoricalComparisonsFuture | WeatherService.weather(for: including: .historicalComparisons) (macOS 15+) |
§Tier-2 note (streams / KVO)
WeatherChange / WeatherUpdate multi-fire
observation and server-sent-event style APIs are deferred to Tier 2
(async Stream pattern).
§Example
use weatherkit::async_api::AsyncWeatherService;
use weatherkit::service::CLLocation;
pollster::block_on(async {
let svc = AsyncWeatherService::shared();
let loc = CLLocation::new(37.3382, -121.8863);
let weather = svc.weather(&loc).await
.map_err(|e| Box::new(e) as Box<dyn std::error::Error>)?;
println!("{:?}", weather.current_weather.condition);
Ok::<_, Box<dyn std::error::Error>>(())
})Structs§
- Async
Weather Service - Async wrapper around
WeatherService. - Attribution
Future - Future returned by
AsyncWeatherService::attribution. - Availability
Future - Future returned by
AsyncWeatherService::availability. - Current
Weather Future - Future returned by
AsyncWeatherService::current_weather. - Daily
Forecast Future - Future returned by
AsyncWeatherService::daily_forecastandAsyncWeatherService::daily_forecast_in. - Historical
Comparisons Future - Future returned by
AsyncWeatherService::historical_comparisons. - Hourly
Forecast Future - Future returned by
AsyncWeatherService::hourly_forecastandAsyncWeatherService::hourly_forecast_in. - Minute
Forecast Future - Future returned by
AsyncWeatherService::minute_forecast. - Weather
Alerts Future - Future returned by
AsyncWeatherService::weather_alerts. - Weather
Changes Future - Future returned by
AsyncWeatherService::weather_changes. - Weather
Future - Future returned by
AsyncWeatherService::weather.