1use std::collections::BTreeMap;
2
3use serde::{Deserialize, Serialize};
4
5pub type Props = BTreeMap<String, Value>;
9
10pub const BRANCHES_PROP: &str = "complexity.branches";
14
15#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
16#[serde(untagged)]
17pub enum Value {
18 Bool(bool),
19 Int(i64),
20 Str(String),
21 List(Vec<Value>),
22 Map(BTreeMap<String, Value>),
23}
24
25impl From<bool> for Value {
26 fn from(v: bool) -> Self {
27 Value::Bool(v)
28 }
29}
30
31impl From<i64> for Value {
32 fn from(v: i64) -> Self {
33 Value::Int(v)
34 }
35}
36
37impl From<&str> for Value {
38 fn from(v: &str) -> Self {
39 Value::Str(v.to_string())
40 }
41}
42
43impl From<String> for Value {
44 fn from(v: String) -> Self {
45 Value::Str(v)
46 }
47}
48
49impl<T: Into<Value>> From<Vec<T>> for Value {
50 fn from(v: Vec<T>) -> Self {
51 Value::List(v.into_iter().map(Into::into).collect())
52 }
53}