fedimint_core::encoding

Trait DynEncodable

Source
pub trait DynEncodable {
    // Required method
    fn consensus_encode_dyn(
        &self,
        writer: &mut dyn Write,
    ) -> Result<usize, Error>;
}
Expand description

Object-safe trait for things that can encode themselves

Like rust-bitcoin’s consensus_encode, but without generics, so can be used in dyn objects.

Required Methods§

Source

fn consensus_encode_dyn(&self, writer: &mut dyn Write) -> Result<usize, Error>

Trait Implementations§

Source§

impl Encodable for Box<dyn DynEncodable>

Source§

fn consensus_encode<W: Write>(&self, writer: &mut W) -> Result<usize, Error>

Encode an object with a well-defined format. Returns the number of bytes written on success. Read more
Source§

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

Self::consensus_encode to newly allocated Vec<u8>
Source§

fn consensus_encode_to_hex(&self) -> String

Encode and convert to hex string representation
Source§

fn consensus_encode_to_len(&self) -> usize

Encode without storing the encoding, return the size
Source§

fn consensus_hash<H>(&self) -> H
where H: Hash, H::Engine: Write,

Generate a SHA256 hash of the consensus encoding using the default hash engine for H. Read more
Source§

fn consensus_hash_sha256(&self) -> Hash

Self::consensus_hash for [bitcoin::hashes::sha256::Hash]
Source§

impl Encodable for dyn DynEncodable

Source§

fn consensus_encode<W: Write>(&self, writer: &mut W) -> Result<usize, Error>

Encode an object with a well-defined format. Returns the number of bytes written on success. Read more
Source§

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

Self::consensus_encode to newly allocated Vec<u8>
Source§

fn consensus_encode_to_hex(&self) -> String

Encode and convert to hex string representation
Source§

fn consensus_encode_to_len(&self) -> usize

Encode without storing the encoding, return the size
Source§

fn consensus_hash<H>(&self) -> H
where H: Hash, H::Engine: Write,

Generate a SHA256 hash of the consensus encoding using the default hash engine for H. Read more
Source§

fn consensus_hash_sha256(&self) -> Hash

Self::consensus_hash for [bitcoin::hashes::sha256::Hash]

Implementors§

Source§

impl<T> DynEncodable for T
where T: Encodable,