pub trait ProtocolEncoding: Sized {
// Required methods
fn encode<W: Write + ?Sized>(&self, writer: &mut W) -> Result<(), Error>;
fn decode<R: Read + ?Sized>(
reader: &mut R,
) -> Result<Self, ProtocolDecodingError>;
// Provided methods
fn serialize(&self) -> Vec<u8> ⓘ { ... }
fn deserialize(byte_slice: &[u8]) -> Result<Self, ProtocolDecodingError> { ... }
fn serialize_hex(&self) -> String { ... }
fn deserialize_hex(hex_str: &str) -> Result<Self, ProtocolDecodingError> { ... }
}Expand description
Trait for encoding objects according to the bark protocol encoding.
Required Methods§
Provided Methods§
Sourcefn deserialize(byte_slice: &[u8]) -> Result<Self, ProtocolDecodingError>
fn deserialize(byte_slice: &[u8]) -> Result<Self, ProtocolDecodingError>
Deserialize object from the given byte slice.
Sourcefn serialize_hex(&self) -> String
fn serialize_hex(&self) -> String
Serialize the object to a lowercase hex string.
Sourcefn deserialize_hex(hex_str: &str) -> Result<Self, ProtocolDecodingError>
fn deserialize_hex(hex_str: &str) -> Result<Self, ProtocolDecodingError>
Deserialize object from hex slice.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.