aboutsummaryrefslogblamecommitdiff
path: root/src/util.rs
blob: e83822e08258dbddbcf43f75450b29e503720fb3 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13
14













                                                                                    
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)
}