Trait lightning_encoding::LightningEncode
source · pub trait LightningEncode {
// Required method
fn lightning_encode<E: Write>(&self, e: E) -> Result<usize, Error>;
// Provided method
fn lightning_serialize(&self) -> Result<Vec<u8>, Error> { ... }
}
Expand description
Lightning-network specific encoding as defined in BOLT-1, 2, 3…
Required Methods§
sourcefn lightning_encode<E: Write>(&self, e: E) -> Result<usize, Error>
fn lightning_encode<E: Write>(&self, e: E) -> Result<usize, Error>
Encode with the given std::io::Write
instance; must return result
with either amount of bytes encoded – or implementation-specific
error type.
Provided Methods§
sourcefn lightning_serialize(&self) -> Result<Vec<u8>, Error>
fn lightning_serialize(&self) -> Result<Vec<u8>, Error>
Serializes data as a byte array using
LightningEncode::lightning_encode
function.
Implementations on Foreign Types§
source§impl<K, V> LightningEncode for (K, V)where
K: LightningEncode + Clone,
V: LightningEncode + Clone,
impl<K, V> LightningEncode for (K, V)where K: LightningEncode + Clone, V: LightningEncode + Clone,
Two-component tuples are encoded as they were fields in the parent data structure