Trait casper_types::bytesrepr::ToBytes
source · pub trait ToBytes {
// Required methods
fn to_bytes(&self) -> Result<Vec<u8>, Error>;
fn serialized_length(&self) -> usize;
// Provided methods
fn into_bytes(self) -> Result<Vec<u8>, Error>
where Self: Sized { ... }
fn write_bytes(&self, writer: &mut Vec<u8>) -> Result<(), Error> { ... }
}
Expand description
A type which can be serialized to a Vec<u8>
.
Required Methods§
sourcefn serialized_length(&self) -> usize
fn serialized_length(&self) -> usize
Returns the length of the Vec<u8>
which would be returned from a successful call to
to_bytes()
or into_bytes()
. The data is not actually serialized, so this call is
relatively cheap.