pub enum DValue {
None,
String(String),
Number(f64),
Boolean(bool),
List(Vec<DValue>),
Dict(HashMap<String, DValue>),
Tuple((Box<DValue>, Box<DValue>)),
BinaryUtil(Binary),
}
Variants§
None
None
String(String)
String
use datastruct::DValue;
DValue::String("hello world".to_string());
Number(f64)
Number
use datastruct::DValue;
DValue::Number(10_f64);
Boolean(bool)
Boolean
use datastruct::DValue;
DValue::Boolean(true);
List(Vec<DValue>)
List
use datastruct::DValue;
DValue::List(vec![
DValue::Number(1.0),
DValue::Number(2.0),
DValue::Number(3.0),
]);
Dict(HashMap<String, DValue>)
Dict
use datastruct::DValue;
DValue::Dict(std::collections::HashMap::new());
Tuple((Box<DValue>, Box<DValue>))
Tuple
use datastruct::DValue;
DValue::Tuple((
Box::new(DValue::Boolean(true)),
Box::new(DValue::Boolean(false)),
));
BinaryUtil(Binary)
Binary
use datastruct::{DValue ,binary_util::Binary};
DValue::BinaryUtil(Binary::new(vec![72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100]));
// or
let from_b64 = "SGVsbG8gV29ybGQ=".to_string();
DValue::BinaryUtil(Binary::from_b64(from_b64).unwrap());
Implementations§
Source§impl DValue
impl DValue
pub fn from(data: &str) -> Self
pub fn from_json(data: &str) -> Self
pub fn to_json(&self) -> String
pub fn weight(&self) -> f64
pub fn size(&self) -> usize
pub fn datatype(&self) -> String
pub fn as_string(&self) -> Option<String>
pub fn as_number(&self) -> Option<f64>
pub fn as_bool(&self) -> Option<bool>
pub fn as_tuple(&self) -> Option<(Box<DValue>, Box<DValue>)>
pub fn as_list(&self) -> Option<Vec<DValue>>
pub fn as_dict(&self) -> Option<HashMap<String, DValue>>
Trait Implementations§
Source§impl<'de> Deserialize<'de> for DValue
impl<'de> Deserialize<'de> for DValue
Source§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
Source§impl Ord for DValue
impl Ord for DValue
Source§impl PartialOrd for DValue
impl PartialOrd for DValue
impl Eq for DValue
Auto Trait Implementations§
impl Freeze for DValue
impl RefUnwindSafe for DValue
impl Send for DValue
impl Sync for DValue
impl Unpin for DValue
impl UnwindSafe for DValue
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more