Easy use, Logging & Example Usage
This commit is contained in:
parent
907b9f04db
commit
1dd240861d
20 changed files with 579 additions and 210 deletions
|
|
@ -2,6 +2,7 @@ use base64::Engine;
|
|||
use base64::engine::general_purpose;
|
||||
use byteorder::{BigEndian, ReadBytesExt, WriteBytesExt};
|
||||
use std::collections::BTreeMap;
|
||||
use std::fmt;
|
||||
use std::hash::{Hash, Hasher};
|
||||
use std::io::Cursor;
|
||||
|
||||
|
|
@ -635,6 +636,44 @@ impl DataValue {
|
|||
}
|
||||
}
|
||||
|
||||
impl fmt::Display for DataValue {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self {
|
||||
DataValue::BoolTrue => write!(f, "true"),
|
||||
DataValue::BoolFalse => write!(f, "false"),
|
||||
DataValue::Bool(v) => write!(f, "{}", v),
|
||||
DataValue::SignedNumber(n) => write!(f, "{}", n),
|
||||
DataValue::UnsignedNumber(n) => write!(f, "{}", n),
|
||||
DataValue::Float(exp, mant) => write!(f, "{}e{}", mant, exp),
|
||||
DataValue::Str(s) => write!(f, "\"{}\"", s),
|
||||
DataValue::Container(entries) => {
|
||||
write!(f, "{{")?;
|
||||
for (i, (key, value)) in entries.iter().enumerate() {
|
||||
if i > 0 {
|
||||
write!(f, ", ")?;
|
||||
}
|
||||
write!(f, "{}: {}", key.0, value)?;
|
||||
}
|
||||
write!(f, "}}")
|
||||
}
|
||||
DataValue::Array(arr) => {
|
||||
write!(f, "[")?;
|
||||
for (i, value) in arr.iter().enumerate() {
|
||||
if i > 0 {
|
||||
write!(f, ", ")?;
|
||||
}
|
||||
write!(f, "{}", value)?;
|
||||
}
|
||||
write!(f, "]")
|
||||
}
|
||||
DataValue::Bytes(_) => write!(f, "(Binary)"),
|
||||
#[cfg(feature = "crypto")]
|
||||
DataValue::EncryptedContainer(_) => write!(f, "(Secure)"),
|
||||
DataValue::Null => write!(f, "null"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl PartialEq for DataValue {
|
||||
fn eq(&self, other: &Self) -> bool {
|
||||
use DataValue::*;
|
||||
|
|
|
|||
Loading…
Reference in a new issue