Enum doson::DataValue [−][src]
pub enum DataValue {
None,
String(String),
Number(f64),
Boolean(bool),
List(Vec<DataValue>),
Dict(HashMap<String, DataValue>),
Tuple((Box<DataValue>, Box<DataValue>)),
Binary(Binary),
}Variants
None Value
Just use for deserialize.
String(String)String Value
use doson::DataValue;
DataValue::String("hello world".to_string());Tuple Fields of String
0: StringNumber(f64)Number Value
use doson::DataValue;
DataValue::Number(10_f64);Tuple Fields of Number
0: f64Boolean(bool)Boolean Value
use doson::DataValue;
DataValue::Boolean(true);Tuple Fields of Boolean
0: boolList Value
use doson::DataValue;
DataValue::List(vec![
DataValue::Number(1.0),
DataValue::Number(2.0),
DataValue::Number(3.0)
]);Dict Value
use doson::DataValue;
DataValue::Dict(std::collections::HashMap::new());Tuple Value
use doson::DataValue;
DataValue::Tuple(
(
Box::new(DataValue::Boolean(true)),
Box::new(DataValue::Boolean(false))
)
);Binary Value
use doson::DataValue;
use doson::binary::Binary;
DataValue::Binary(
Binary::build(vec![72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100])
)
// or
let from_base64: = "SGVsbG8gV29ybGQ=";
DataValue::Binary(
Binary::from_base64(from_base64)
)
Implementations
parse &str to DataValue type:
- String: “xxx”
- Number: 114514
- Boolean: true
- List: [1,2,3,4,5]
- dict: {“hello”: “world”}
- tuple: (1,2)
use doson::DataValue;
assert_eq!(
DataValue::from("[1,2,3]"),
DataValue::List(vec![
DataValue::Number(1_f64),
DataValue::Number(2_f64),
DataValue::Number(3_f64),
])
);Trait Implementations
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
This method returns an ordering between self and other values if one exists. Read more
This method tests less than (for self and other) and is used by the < operator. Read more
This method tests less than or equal to (for self and other) and is used by the <=
operator. Read more
This method tests greater than (for self and other) and is used by the > operator. Read more
Auto Trait Implementations
impl RefUnwindSafe for DataValue
impl UnwindSafe for DataValue
Blanket Implementations
Mutably borrows from an owned value. Read more