use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(untagged)]
pub enum FormatSetting {
String(String),
Schema(serde_json::Value),
}
impl FormatSetting {
pub fn json() -> Self {
Self::String("json".to_string())
}
pub fn string(format: impl Into<String>) -> Self {
Self::String(format.into())
}
pub fn schema(schema: serde_json::Value) -> Self {
Self::Schema(schema)
}
}
impl From<&str> for FormatSetting {
fn from(s: &str) -> Self {
Self::String(s.to_string())
}
}
impl From<serde_json::Value> for FormatSetting {
fn from(v: serde_json::Value) -> Self {
Self::Schema(v)
}
}