15 lines
321 B
Rust
15 lines
321 B
Rust
|
use serde::Serialize;
|
||
|
|
||
|
// util
|
||
|
pub fn rmp_to_vec_all_named<T>(val: &T) -> Result<Vec<u8>, rmp_serde::encode::Error>
|
||
|
where
|
||
|
T: Serialize + ?Sized,
|
||
|
{
|
||
|
let mut wr = Vec::with_capacity(128);
|
||
|
let mut se = rmp_serde::Serializer::new(&mut wr)
|
||
|
.with_struct_map()
|
||
|
.with_string_variants();
|
||
|
val.serialize(&mut se)?;
|
||
|
Ok(wr)
|
||
|
}
|