pub trait Encode {
// Required method
fn encode(&self, bytes: &mut Vec<u8>) -> Result<(), CodecError>;
// Provided methods
fn get_encoded(&self) -> Result<Vec<u8>, CodecError> { ... }
fn encoded_len(&self) -> Option<usize> { ... }
}
Expand description
Describes how to encode objects into a byte sequence.
Required Methods§
Provided Methods§
Sourcefn get_encoded(&self) -> Result<Vec<u8>, CodecError>
fn get_encoded(&self) -> Result<Vec<u8>, CodecError>
Convenience method to encode a value into a new Vec<u8>
.
Sourcefn encoded_len(&self) -> Option<usize>
fn encoded_len(&self) -> Option<usize>
Returns an optional hint indicating how many bytes will be required to encode this value, or
None
by default.