use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ThinkSetting {
Enabled(bool),
Level(String),
}
impl ThinkSetting {
pub fn enabled() -> Self {
Self::Enabled(true)
}
pub fn disabled() -> Self {
Self::Enabled(false)
}
pub fn level(level: impl Into<String>) -> Self {
Self::Level(level.into())
}
pub fn high() -> Self {
Self::Level("high".to_string())
}
pub fn medium() -> Self {
Self::Level("medium".to_string())
}
pub fn low() -> Self {
Self::Level("low".to_string())
}
}
impl From<bool> for ThinkSetting {
fn from(b: bool) -> Self {
Self::Enabled(b)
}
}
impl From<&str> for ThinkSetting {
fn from(s: &str) -> Self {
Self::Level(s.to_string())
}
}