use serde::{Deserialize, Serialize};
use serde_json::Value;
use std::convert::From;
#[derive(Debug, Deserialize, Serialize, PartialEq, Clone)]
#[serde(untagged)]
pub enum ExtensionValue {
String(String),
Boolean(bool),
Integer(i64),
Json(Value),
}
impl From<String> for ExtensionValue {
fn from(s: String) -> Self {
ExtensionValue::String(s)
}
}
impl From<bool> for ExtensionValue {
fn from(s: bool) -> Self {
ExtensionValue::Boolean(s)
}
}
impl From<i64> for ExtensionValue {
fn from(s: i64) -> Self {
ExtensionValue::Integer(s)
}
}
impl From<Value> for ExtensionValue {
fn from(s: Value) -> Self {
ExtensionValue::Json(s)
}
}
impl ExtensionValue {
pub fn from_string<S>(s: S) -> Self
where
S: Into<String>,
{
ExtensionValue::from(s.into())
}
pub fn from_i64<S>(s: S) -> Self
where
S: Into<i64>,
{
ExtensionValue::from(s.into())
}
pub fn from_bool<S>(s: S) -> Self
where
S: Into<bool>,
{
ExtensionValue::from(s.into())
}
pub fn from_json_value<S>(s: S) -> Self
where
S: Into<serde_json::Value>,
{
ExtensionValue::from(s.into())
}
}