/// Encode trait for your own encoding method. /// /// Example: /// ```rust /// pub struct Bincode; /// /// impl native_model::Encode for Bincode { /// type Error = bincode::error::EncodeError; /// fn encode(obj: &T) -> Result, bincode::error::EncodeError> { /// bincode::encode_to_vec(obj, bincode::config::standard()) /// } /// } /// ``` pub trait Encode { type Error; fn encode(obj: &T) -> Result, Self::Error>; } /// Decode trait for your own decoding method. /// /// Example: /// ```rust /// pub struct Bincode; /// /// impl native_model::Decode for Bincode { /// type Error = bincode::error::DecodeError; /// fn decode(data: Vec) -> Result { /// bincode::decode_from_slice(&data, bincode::config::standard()).map(|(result, _)| result) /// } /// } pub trait Decode { type Error; fn decode(data: Vec) -> Result; }