feat: default bincode 1.3.3

This commit is contained in:
Vincent Herlemont
2023-10-29 09:41:42 +01:00
parent ac601f4c98
commit 383379fe1e
11 changed files with 48 additions and 3 deletions
@@ -0,0 +1,19 @@
use bincode_1_3::{deserialize, serialize, Error};
use serde::{Deserialize, Serialize};
#[derive(Default)]
pub struct Bincode;
impl<T: Serialize> super::Encode<T> for Bincode {
type Error = Error;
fn encode(obj: &T) -> Result<Vec<u8>, Error> {
Ok(serialize(obj)?)
}
}
impl<T: for<'a> Deserialize<'a>> super::Decode<T> for Bincode {
type Error = Error;
fn decode(data: Vec<u8>) -> Result<T, Error> {
Ok(deserialize(&data[..])?)
}
}
+2
View File
@@ -1,3 +1,5 @@
pub mod bincode_1_3;
/// Encode trait for your own encoding method.
///
/// Example: