docs: add some encode docs (#1797)

This commit is contained in:
Matthias Seitz
2023-03-16 17:07:55 +01:00
committed by GitHub
parent 9f00d48402
commit 6bd9a25980

View File

@@ -70,7 +70,12 @@ macro_rules! impl_max_encoded_len {
#[auto_impl(&)]
#[cfg_attr(feature = "alloc", auto_impl(Box, Arc))]
pub trait Encodable {
/// Appends the rlp encoded object to the specified output buffer.
fn encode(&self, out: &mut dyn BufMut);
/// Returns the length of the encoded object.
///
/// NOTE: This includes the length of the rlp [Header].
fn length(&self) -> usize {
let mut out = BytesMut::new();
self.encode(&mut out);