ProtocolEncoding

Trait ProtocolEncoding 

Source
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§

Source

fn encode<W: Write + ?Sized>(&self, writer: &mut W) -> Result<(), Error>

Encode the object into the writer.

Source

fn decode<R: Read + ?Sized>( reader: &mut R, ) -> Result<Self, ProtocolDecodingError>

Decode the object from the writer.

Provided Methods§

Source

fn serialize(&self) -> Vec<u8>

Serialize the object into a byte vector.

Source

fn deserialize(byte_slice: &[u8]) -> Result<Self, ProtocolDecodingError>

Deserialize object from the given byte slice.

Source

fn serialize_hex(&self) -> String

Serialize the object to a lowercase hex string.

Source

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.

Implementations on Foreign Types§

Source§

impl ProtocolEncoding for Option<PublicKey>

Source§

impl ProtocolEncoding for Option<Signature>

Source§

impl ProtocolEncoding for BlockHash

Source§

impl ProtocolEncoding for OutPoint

Source§

impl ProtocolEncoding for TxOut

Source§

impl ProtocolEncoding for Hash

Source§

impl ProtocolEncoding for PublicKey

Source§

impl ProtocolEncoding for Signature

Source§

impl<'a, T: ProtocolEncoding + Clone> ProtocolEncoding for Cow<'a, T>

Source§

fn encode<W: Write + ?Sized>(&self, writer: &mut W) -> Result<(), Error>

Source§

fn decode<R: Read + ?Sized>( reader: &mut R, ) -> Result<Self, ProtocolDecodingError>

Implementors§