messagepack_async/
value.rs

1mod ext;
2mod r#float;
3mod r#int;
4
5pub use ext::Ext;
6pub use r#float::Float;
7pub use r#int::Int;
8
9#[derive(Clone, Debug, PartialEq)]
10pub enum Value {
11    Nil,
12    Bool(bool),
13    Int(Int),
14    Float(Float),
15    Str(String),
16    Bin(Vec<u8>),
17    Arr(Vec<Value>),
18    Map(Vec<(Value, Value)>),
19    Ext(Ext),
20}
21
22impl From<()> for Value {
23    fn from(_: ()) -> Self {
24        Value::Nil
25    }
26}
27
28impl From<bool> for Value {
29    fn from(value: bool) -> Self {
30        Value::Bool(value)
31    }
32}
33
34impl From<&str> for Value {
35    fn from(value: &str) -> Self {
36        Self::Str(value.into())
37    }
38}
39
40impl From<Vec<u8>> for Value {
41    fn from(value: Vec<u8>) -> Self {
42        Self::Bin(value)
43    }
44}
45
46impl From<String> for Value {
47    fn from(value: String) -> Self {
48        Self::Str(value)
49    }
50}
51
52impl From<Vec<Value>> for Value {
53    fn from(value: Vec<Value>) -> Self {
54        Self::Arr(value)
55    }
56}
57
58impl From<Vec<(Value, Value)>> for Value {
59    fn from(value: Vec<(Value, Value)>) -> Self {
60        Self::Map(value)
61    }
62}