test: fix test readme
This commit is contained in:
@@ -9,12 +9,14 @@ pub mod postcard_1_0;
|
||||
///
|
||||
/// Example:
|
||||
/// ```rust
|
||||
/// use bincode_2_rc::{error::EncodeError,serde::encode_to_vec, config::standard};
|
||||
/// use serde::Serialize;
|
||||
/// pub struct Bincode;
|
||||
///
|
||||
/// impl<T: bincode::Encode> native_model::Encode<T> for Bincode {
|
||||
/// type Error = bincode::error::EncodeError;
|
||||
/// fn encode(obj: &T) -> Result<Vec<u8>, bincode::error::EncodeError> {
|
||||
/// bincode::encode_to_vec(obj, bincode::config::standard())
|
||||
/// impl<T: Serialize> native_model::Encode<T> for Bincode {
|
||||
/// type Error = EncodeError;
|
||||
/// fn encode(obj: &T) -> Result<Vec<u8>, EncodeError> {
|
||||
/// Ok(encode_to_vec(&obj, standard())?)
|
||||
/// }
|
||||
/// }
|
||||
/// ```
|
||||
@@ -27,12 +29,14 @@ pub trait Encode<T> {
|
||||
///
|
||||
/// Example:
|
||||
/// ```rust
|
||||
/// use bincode_2_rc::{error::DecodeError,serde::decode_from_slice, config::standard};
|
||||
/// use serde::Deserialize;
|
||||
/// pub struct Bincode;
|
||||
///
|
||||
/// impl<T: bincode::Decode> native_model::Decode<T> for Bincode {
|
||||
/// type Error = bincode::error::DecodeError;
|
||||
/// fn decode(data: Vec<u8>) -> Result<T, bincode::error::DecodeError> {
|
||||
/// bincode::decode_from_slice(&data, bincode::config::standard()).map(|(result, _)| result)
|
||||
/// impl<T: for<'a> Deserialize<'a>> native_model::Decode<T> for Bincode {
|
||||
/// type Error = DecodeError;
|
||||
/// fn decode(data: Vec<u8>) -> Result<T, DecodeError> {
|
||||
/// Ok(decode_from_slice(&data, standard())?.0)
|
||||
/// }
|
||||
/// }
|
||||
pub trait Decode<T> {
|
||||
|
||||
Reference in New Issue
Block a user