feat: default bincode 2.0.0-rc.*

This commit is contained in:
Vincent Herlemont
2023-10-29 09:42:30 +01:00
parent 383379fe1e
commit 39466299ed
22 changed files with 68 additions and 11 deletions
@@ -0,0 +1,22 @@
use bincode_2_rc::{
config,
error::{DecodeError, EncodeError},
serde::{decode_from_slice, encode_to_vec},
};
use serde::{Deserialize, Serialize};
pub struct Bincode;
impl<T: Serialize> super::Encode<T> for Bincode {
type Error = EncodeError;
fn encode(obj: &T) -> Result<Vec<u8>, EncodeError> {
encode_to_vec(obj, config::standard())
}
}
impl<T: for<'a> Deserialize<'a>> super::Decode<T> for Bincode {
type Error = DecodeError;
fn decode(data: Vec<u8>) -> Result<T, DecodeError> {
Ok(decode_from_slice(&data, config::standard())?.0)
}
}
+1
View File
@@ -1,4 +1,5 @@
pub mod bincode_1_3;
pub mod bincode_2_rc;
/// Encode trait for your own encoding method.
///