use std::borrow::Cow;
use crate::query::AsApiStr;
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
#[non_exhaustive]
pub enum AirQualityHourlyVar {
Pm10,
Pm2_5,
CarbonMonoxide,
CarbonDioxide,
NitrogenDioxide,
SulphurDioxide,
Ozone,
AerosolOpticalDepth,
Dust,
UvIndex,
UvIndexClearSky,
Ammonia,
Methane,
AlderPollen,
BirchPollen,
GrassPollen,
MugwortPollen,
OlivePollen,
RagweedPollen,
EuropeanAqi,
EuropeanAqiPm2_5,
EuropeanAqiPm10,
EuropeanAqiNitrogenDioxide,
EuropeanAqiOzone,
EuropeanAqiSulphurDioxide,
UsAqi,
UsAqiPm2_5,
UsAqiPm10,
UsAqiNitrogenDioxide,
UsAqiOzone,
UsAqiSulphurDioxide,
UsAqiCarbonMonoxide,
Formaldehyde,
Glyoxal,
NonMethaneVolatileOrganicCompounds,
Pm10Wildfires,
PeroxyacylNitrates,
SecondaryInorganicAerosol,
ResidentialElementaryCarbon,
TotalElementaryCarbon,
Pm2_5TotalOrganicMatter,
SeaSaltAerosol,
NitrogenMonoxide,
Other(Cow<'static, str>),
}
impl AirQualityHourlyVar {
pub fn other(token: impl Into<Cow<'static, str>>) -> Self {
Self::Other(token.into())
}
}
impl AsApiStr for AirQualityHourlyVar {
fn as_api_str(&self) -> Cow<'static, str> {
match self {
Self::Pm10 => Cow::Borrowed("pm10"),
Self::Pm2_5 => Cow::Borrowed("pm2_5"),
Self::CarbonMonoxide => Cow::Borrowed("carbon_monoxide"),
Self::CarbonDioxide => Cow::Borrowed("carbon_dioxide"),
Self::NitrogenDioxide => Cow::Borrowed("nitrogen_dioxide"),
Self::SulphurDioxide => Cow::Borrowed("sulphur_dioxide"),
Self::Ozone => Cow::Borrowed("ozone"),
Self::AerosolOpticalDepth => Cow::Borrowed("aerosol_optical_depth"),
Self::Dust => Cow::Borrowed("dust"),
Self::UvIndex => Cow::Borrowed("uv_index"),
Self::UvIndexClearSky => Cow::Borrowed("uv_index_clear_sky"),
Self::Ammonia => Cow::Borrowed("ammonia"),
Self::Methane => Cow::Borrowed("methane"),
Self::AlderPollen => Cow::Borrowed("alder_pollen"),
Self::BirchPollen => Cow::Borrowed("birch_pollen"),
Self::GrassPollen => Cow::Borrowed("grass_pollen"),
Self::MugwortPollen => Cow::Borrowed("mugwort_pollen"),
Self::OlivePollen => Cow::Borrowed("olive_pollen"),
Self::RagweedPollen => Cow::Borrowed("ragweed_pollen"),
Self::EuropeanAqi => Cow::Borrowed("european_aqi"),
Self::EuropeanAqiPm2_5 => Cow::Borrowed("european_aqi_pm2_5"),
Self::EuropeanAqiPm10 => Cow::Borrowed("european_aqi_pm10"),
Self::EuropeanAqiNitrogenDioxide => Cow::Borrowed("european_aqi_nitrogen_dioxide"),
Self::EuropeanAqiOzone => Cow::Borrowed("european_aqi_ozone"),
Self::EuropeanAqiSulphurDioxide => Cow::Borrowed("european_aqi_sulphur_dioxide"),
Self::UsAqi => Cow::Borrowed("us_aqi"),
Self::UsAqiPm2_5 => Cow::Borrowed("us_aqi_pm2_5"),
Self::UsAqiPm10 => Cow::Borrowed("us_aqi_pm10"),
Self::UsAqiNitrogenDioxide => Cow::Borrowed("us_aqi_nitrogen_dioxide"),
Self::UsAqiOzone => Cow::Borrowed("us_aqi_ozone"),
Self::UsAqiSulphurDioxide => Cow::Borrowed("us_aqi_sulphur_dioxide"),
Self::UsAqiCarbonMonoxide => Cow::Borrowed("us_aqi_carbon_monoxide"),
Self::Formaldehyde => Cow::Borrowed("formaldehyde"),
Self::Glyoxal => Cow::Borrowed("glyoxal"),
Self::NonMethaneVolatileOrganicCompounds => {
Cow::Borrowed("non_methane_volatile_organic_compounds")
}
Self::Pm10Wildfires => Cow::Borrowed("pm10_wildfires"),
Self::PeroxyacylNitrates => Cow::Borrowed("peroxyacyl_nitrates"),
Self::SecondaryInorganicAerosol => Cow::Borrowed("secondary_inorganic_aerosol"),
Self::ResidentialElementaryCarbon => Cow::Borrowed("residential_elementary_carbon"),
Self::TotalElementaryCarbon => Cow::Borrowed("total_elementary_carbon"),
Self::Pm2_5TotalOrganicMatter => Cow::Borrowed("pm2_5_total_organic_matter"),
Self::SeaSaltAerosol => Cow::Borrowed("sea_salt_aerosol"),
Self::NitrogenMonoxide => Cow::Borrowed("nitrogen_monoxide"),
Self::Other(token) => token.clone(),
}
}
}
pub type AirQualityCurrentVar = AirQualityHourlyVar;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
#[non_exhaustive]
pub enum AirQualityDomain {
Auto,
CamsEurope,
CamsGlobal,
}
impl AsApiStr for AirQualityDomain {
fn as_api_str(&self) -> Cow<'static, str> {
Cow::Borrowed(match self {
Self::Auto => "auto",
Self::CamsEurope => "cams_europe",
Self::CamsGlobal => "cams_global",
})
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn custom_air_quality_variable_token_is_passed_through() {
assert_eq!(
AirQualityHourlyVar::other("new_air_quality_metric").as_api_str(),
"new_air_quality_metric"
);
}
}