mln-rs-style 0.0.21

Part of mln-rs, a MapLibre map renderer written in Rust. Depend on mln-rs instead.
Documentation
// A JSON-like value that, unlike serde_json::Value, distinguishes
// u64/i64/f64: the expression and conversion code depends on that
// distinction.

/// An object's members, iterated in key order, so that serializing one is
/// deterministic.
pub type ValueObject = crate::collections::VecMap<String, Value>;

/// A feature property's or a style value's JSON-like value.
#[derive(Clone, Debug, Default, PartialEq, mln_wire::Wire)]
pub enum Value {
    #[default]
    Null,
    Bool(bool),
    Uint(u64),
    Int(i64),
    Double(f64),
    String(String),
    Array(Vec<Value>),
    Object(ValueObject),
}

impl From<bool> for Value {
    fn from(v: bool) -> Self {
        Value::Bool(v)
    }
}
impl From<u64> for Value {
    fn from(v: u64) -> Self {
        Value::Uint(v)
    }
}
impl From<i64> for Value {
    fn from(v: i64) -> Self {
        Value::Int(v)
    }
}
impl From<f64> for Value {
    fn from(v: f64) -> Self {
        Value::Double(v)
    }
}
impl From<&str> for Value {
    fn from(v: &str) -> Self {
        Value::String(v.to_owned())
    }
}
impl From<String> for Value {
    fn from(v: String) -> Self {
        Value::String(v)
    }
}
impl From<Vec<Value>> for Value {
    fn from(v: Vec<Value>) -> Self {
        Value::Array(v)
    }
}
impl From<ValueObject> for Value {
    fn from(v: ValueObject) -> Self {
        Value::Object(v)
    }
}