pub trait Encodable {
// Required method
fn consensus_encode<W: Write>(&self, writer: &mut W) -> Result<usize, Error>;
// Provided methods
fn consensus_encode_to_vec(&self) -> Vec<u8> ⓘ { ... }
fn consensus_encode_to_hex(&self) -> String { ... }
fn consensus_encode_to_len(&self) -> usize { ... }
fn consensus_hash<H>(&self) -> H
where H: Hash,
H::Engine: Write { ... }
fn consensus_hash_sha256(&self) -> Hash { ... }
}
Expand description
Data which can be encoded in a consensus-consistent way
Required Methods§
Provided Methods§
Sourcefn consensus_encode_to_vec(&self) -> Vec<u8> ⓘ
fn consensus_encode_to_vec(&self) -> Vec<u8> ⓘ
Self::consensus_encode
to newly allocated Vec<u8>
Sourcefn consensus_encode_to_hex(&self) -> String
fn consensus_encode_to_hex(&self) -> String
Encode and convert to hex string representation
Sourcefn consensus_encode_to_len(&self) -> usize
fn consensus_encode_to_len(&self) -> usize
Encode without storing the encoding, return the size
Sourcefn consensus_hash<H>(&self) -> H
fn consensus_hash<H>(&self) -> H
Generate a SHA256 hash of the consensus encoding using the default hash
engine for H
.
Can be used to validate all federation members agree on state without revealing the object
Sourcefn consensus_hash_sha256(&self) -> Hash
fn consensus_hash_sha256(&self) -> Hash
Self::consensus_hash
for [bitcoin::hashes::sha256::Hash
]
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.