aerocontext-core 0.4.1

Provider-neutral aeronautical-context model and the pluggable ContextProvider contract
Documentation
//! The weather-briefing capability.

use async_trait::async_trait;

use crate::model::{AreaBriefingRequest, Briefing};
use crate::provider::{ContextProvider, ProviderError};
use crate::route_request::RouteBriefingRequest;

/// A provider that can serve an area weather briefing.
///
/// The synchronous request/response weather capability: METAR, TAF, PIREP,
/// SIGMET and similar products for an [`crate::Area`]. A future datalink
/// source such as FIS-B is just another implementor — additive, with no
/// breaking change to this trait or to the `#[non_exhaustive]`
/// [`Briefing`] / [`crate::Product`] it returns.
#[async_trait(?Send)]
pub trait WeatherBriefingProvider: ContextProvider {
    /// Fetch a simple area weather briefing.
    async fn area_briefing(&self, request: &AreaBriefingRequest)
    -> Result<Briefing, ProviderError>;

    /// Fetch a briefing for a route corridor.
    ///
    /// Defaulted to `Unsupported` so the capability is additive: a
    /// provider with a native route product (Leidos) overrides it, and a
    /// provider that only knows areas can be driven over
    /// [`RouteBriefingRequest::segment_bboxes`] by the caller. The
    /// default never silently degrades a route into a single area.
    async fn route_briefing(
        &self,
        _request: &RouteBriefingRequest,
    ) -> Result<Briefing, ProviderError> {
        Err(ProviderError::Unsupported {
            reason: format!("{} has no route-briefing capability", self.name()),
        })
    }
}