Chunkable

Trait Chunkable 

Source
pub trait Chunkable {
    type Error: Debug;

    // Required method
    fn as_bytes(&self) -> Result<Cow<'_, Vec<u8>>, Self::Error>;

    // Provided method
    fn hash(&self) -> Result<Digest, Self::Error> { ... }
}
Expand description

Implemented for types that are chunked when sending over the wire and/or before storing the trie store.

Required Associated Types§

Source

type Error: Debug

Error returned when mapping Self into bytes.

Required Methods§

Source

fn as_bytes(&self) -> Result<Cow<'_, Vec<u8>>, Self::Error>

Maps Self into bytes.

Returns a Cow instance in case the resulting bytes are the same as input and we don’t want to reinitialize. This also helps with a case where returning a vector of bytes would require instantiating a Vec<u8> locally (see casper_types::bytesrepr::ToBytes) but can’t be returned as reference. Alternative encoding would be to consume Self and return Vec<u8> but that may do it unnecessarily if Self would be to used again.

Provided Methods§

Source

fn hash(&self) -> Result<Digest, Self::Error>

Serializes the self using the Chunkable implementation for that type and returns a Digest of the serialized bytes.

Implementations on Foreign Types§

Source§

impl Chunkable for &Vec<ExecutionResult>

Source§

type Error = Error

Source§

fn as_bytes(&self) -> Result<Cow<'_, Vec<u8>>, Self::Error>

Source§

impl Chunkable for Vec<&ExecutionResultV1>

Source§

type Error = Error

Source§

fn as_bytes(&self) -> Result<Cow<'_, Vec<u8>>, Self::Error>

Source§

impl Chunkable for Vec<&ExecutionResultV2>

Source§

type Error = Error

Source§

fn as_bytes(&self) -> Result<Cow<'_, Vec<u8>>, Self::Error>

Source§

impl Chunkable for Vec<ExecutionResult>

Source§

type Error = Error

Source§

fn as_bytes(&self) -> Result<Cow<'_, Vec<u8>>, Self::Error>

Source§

impl Chunkable for Vec<u8>

Source§

type Error = Infallible

Source§

fn as_bytes(&self) -> Result<Cow<'_, Vec<u8>>, Self::Error>

Source§

impl Chunkable for Bytes

Source§

type Error = Infallible

Source§

fn as_bytes(&self) -> Result<Cow<'_, Vec<u8>>, Self::Error>

Implementors§