use serde::{Deserialize, Serialize};
use serde_variant::to_variant_name;

#[derive(Debug, Default, Deserialize, Serialize)]
pub struct Cache {
    #[serde(default)]
    pub driver: Driver,
}

#[derive(Debug, Default, Deserialize, Serialize)]
pub enum Driver {
    #[default]
    #[serde(rename = "null")]
    Null,
    #[cfg(feature = "memory")]
    #[serde(rename = "memory")]
    Memory,
}

impl std::fmt::Display for Driver {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        to_variant_name(self).expect("only enum supported").fmt(f)
    }
}
