mirror of
https://github.com/euzu/tuliprox.git
synced 2026-10-28 09:42:26 +01:00
stream properties refactored
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
use std::io;
|
||||
use log::error;
|
||||
use shared::error::to_io_error;
|
||||
|
||||
#[inline]
|
||||
pub fn binary_serialize<T>(value: &T) -> io::Result<Vec<u8>>
|
||||
where
|
||||
T: ?Sized + serde::Serialize,
|
||||
{
|
||||
rmp_serde::to_vec(value).map_err(to_io_error)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn binary_deserialize<T>(value: &[u8]) -> io::Result<T>
|
||||
where
|
||||
T: for<'a> serde::Deserialize<'a>,
|
||||
{
|
||||
rmp_serde::from_slice(value).map_err(|e| {
|
||||
error!("Failed to decode {e}");
|
||||
to_io_error(e)
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user