Skip to content
Snippets Groups Projects
Commit 653a4309 authored by Sébastien Blin's avatar Sébastien Blin Committed by Adrien Béraud
Browse files

rust: value to bytes

parent 48b763f1
Branches
Tags
No related merge requests found
...@@ -49,6 +49,14 @@ impl Value { ...@@ -49,6 +49,14 @@ impl Value {
} }
} }
pub fn as_bytes(&self) -> Vec<u8> {
unsafe {
let dv = dht_value_get_data(self);
let slice = slice::from_raw_parts_mut(dv.data as *mut _, dv.size);
slice.to_vec()
}
}
pub fn boxed(&mut self) -> Box<Value> { pub fn boxed(&mut self) -> Box<Value> {
unsafe { unsafe {
Box::from_raw(dht_value_ref(self)) Box::from_raw(dht_value_ref(self))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment