diff --git a/firmware/src/json.rs b/firmware/src/json.rs index 655555f..5c16f0a 100644 --- a/firmware/src/json.rs +++ b/firmware/src/json.rs @@ -16,6 +16,48 @@ pub enum Value { Object(Vec<(String, Value)>), } +impl From<()> for Value { + fn from(_value: ()) -> Self { + Self::Null + } +} + +impl From for Value { + fn from(value: bool) -> Self { + Self::Boolean(value) + } +} + +impl From for Value { + fn from(value: f64) -> Self { + Self::Number(value) + } +} + +impl From<&str> for Value { + fn from(value: &str) -> Self { + Self::String(value.to_string()) + } +} + +impl From for Value { + fn from(value: String) -> Self { + Self::String(value) + } +} + +impl From> for Value { + fn from(value: Vec) -> Self { + Self::Array(value) + } +} + +impl From> for Value { + fn from(value: Vec<(String, Value)>) -> Self { + Self::Object(value) + } +} + impl TryFrom for bool { type Error = Error<()>;