myutil 7.3.0

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

#[inline(always)]
pub fn encode<T>(t: &T) -> Result<Vec<u8>>
where
    T: Serialize,
{
    rmp::to_vec(&t).c(d!())
}

#[inline(always)]
pub fn decode<T>(bytes: &[u8]) -> Result<T>
where
    T: for<'a> Deserialize<'a>,
{
    rmp::from_slice(bytes).c(d!())
}