Trait stacks_common::codec::StacksMessageCodec
source · pub trait StacksMessageCodec {
// Required methods
fn consensus_serialize<W: Write>(&self, fd: &mut W) -> Result<(), Error>
where Self: Sized;
fn consensus_deserialize<R: Read>(fd: &mut R) -> Result<Self, Error>
where Self: Sized;
// Provided method
fn serialize_to_vec(&self) -> Vec<u8>
where Self: Sized { ... }
}
Expand description
Helper trait for various primitive types that make up Stacks messages
Required Methods§
sourcefn consensus_serialize<W: Write>(&self, fd: &mut W) -> Result<(), Error>where
Self: Sized,
fn consensus_serialize<W: Write>(&self, fd: &mut W) -> Result<(), Error>where Self: Sized,
serialize implementors should never error unless there is an underlying
failure in writing to the fd
fn consensus_deserialize<R: Read>(fd: &mut R) -> Result<Self, Error>where Self: Sized,
Provided Methods§
sourcefn serialize_to_vec(&self) -> Vec<u8>where
Self: Sized,
fn serialize_to_vec(&self) -> Vec<u8>where Self: Sized,
Convenience for serialization to a vec. this function unwraps any underlying serialization error