1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
use std::{borrow::Cow, collections::HashMap, ops::Deref, sync::Arc};

#[derive(Debug)]
pub struct WildDocValue {
    value: serde_json::Value,
}
impl Deref for WildDocValue {
    type Target = serde_json::Value;

    fn deref(&self) -> &Self::Target {
        &self.value
    }
}
impl WildDocValue {
    pub fn new(value: serde_json::Value) -> Self {
        Self { value }
    }
    pub fn value(&self)->&serde_json::Value{
        &self.value
    }
    pub fn to_str<'a>(&'a self) -> Cow<'a, str> {
        if let Some(s) = self.value.as_str() {
            Cow::Borrowed(s)
        } else {
            Cow::Owned(self.value.to_string())
        }
    }
}
pub type VarsStack = Vec<HashMap<Vec<u8>, Arc<WildDocValue>>>;