Enable conversion to/from Vec<u8> for record values
This commit is contained in:
parent
811064bb05
commit
a9978fdcda
1 changed files with 16 additions and 0 deletions
|
@ -386,6 +386,18 @@ impl From<Option<String>> for Value {
|
|||
}
|
||||
}
|
||||
|
||||
impl Into<Vec<u8>> for Value {
|
||||
fn into(self) -> Vec<u8> {
|
||||
serde_cbor::to_vec(&self).unwrap()
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Vec<u8>> for Value {
|
||||
fn from(v: Vec<u8>) -> Self {
|
||||
serde_cbor::from_slice::<Value>(&v).unwrap()
|
||||
}
|
||||
}
|
||||
|
||||
impl Value {
|
||||
// -----------------------------------
|
||||
// Initial record value
|
||||
|
@ -600,6 +612,10 @@ impl Value {
|
|||
.into()
|
||||
}
|
||||
|
||||
pub fn to_vec(&self) -> Result<Vec<u8>, Error> {
|
||||
serde_cbor::to_vec(&self).map_err(|e| e.into())
|
||||
}
|
||||
|
||||
// -----------------------------------
|
||||
// Value operations
|
||||
// -----------------------------------
|
||||
|
|
Loading…
Reference in a new issue