Skip to main content

ForecastSource

Trait ForecastSource 

Source
pub trait ForecastSource:
    Debug
    + Send
    + Sync {
    // Required methods
    fn carbon_intensity_forecast(
        &self,
        region: &str,
        hours: usize,
    ) -> Result<Vec<CarbonForecast>>;
    fn energy_price_forecast(
        &self,
        region: &str,
        hours: usize,
    ) -> Result<Vec<EnergyPriceForecast>>;
}
Expand description

Supplies real carbon-intensity and energy-price forecasts for EnvironmentalMonitor::optimize_scheduling.

Implementations are expected to already hold (or synchronously look up) this data – e.g. from a cache a caller-owned background task keeps refreshed from a real grid-carbon-intensity API (WattTime, Electricity Maps, …) or a utility’s spot-price feed – since EnvironmentalMonitor performs no network I/O of its own. Without one attached, EnvironmentalMonitor::optimize_scheduling fails with EnvironmentalMonitorError::NotConfigured instead of fabricating a forecast.

Required Methods§

Source

fn carbon_intensity_forecast( &self, region: &str, hours: usize, ) -> Result<Vec<CarbonForecast>>

Real carbon-intensity forecast for region, one entry per hour for the next hours hours.

Source

fn energy_price_forecast( &self, region: &str, hours: usize, ) -> Result<Vec<EnergyPriceForecast>>

Real energy-price forecast for region, one entry per hour for the next hours hours.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§