eva_common/
payload.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use crate::EResult;
use serde::{Deserialize, Serialize};

#[inline]
pub fn pack<T>(val: &T) -> EResult<Vec<u8>>
where
    T: Serialize + ?Sized,
{
    rmp_serde::to_vec_named(val).map_err(Into::into)
}

#[inline]
pub fn unpack<'a, T>(input: &'a [u8]) -> EResult<T>
where
    T: Deserialize<'a>,
{
    rmp_serde::from_slice(input).map_err(Into::into)
}