use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct ValuesMap {
#[serde(rename = "type")]
pub value_type: ValueType,
pub values: Vec<Value>,
}
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct ValueType(
#[serde(deserialize_with = "crate::string_within_range_inclusive::<1, 128, _>")] pub String,
);
#[derive(Clone, Debug, Serialize, Deserialize)]
#[serde(untagged)]
pub enum Value {
Integer(i64),
Number(f64),
Boolean(bool),
Point(Point),
String(String),
}
impl PartialEq for Value {
fn eq(&self, other: &Self) -> bool {
match (self, other) {
(Self::Integer(s), Self::Integer(o)) => s == o,
(Self::Boolean(s), Self::Boolean(o)) => s == o,
(Self::Point(s), Self::Point(o)) => s == o,
(Self::String(s), Self::String(o)) => s == o,
(Self::Number(s), Self::Number(o)) if s.is_nan() && o.is_nan() => true,
(Self::Number(s), Self::Number(o)) => s == o,
_ => false,
}
}
}
impl Eq for Value {}
#[derive(Clone, Debug, PartialEq, Default, Serialize, Deserialize)]
pub struct Point {
pub x: f32,
pub y: f32,
}
impl Point {
pub fn new(x: f32, y: f32) -> Self {
Self { x, y }
}
}