Trait cumulus_primitives_core::relay_chain::EncodeAs

source ·
pub trait EncodeAs<T> {
    // Required method
    fn encode_as(&self) -> Vec<u8> ;
}
Expand description

This helper trait ensures that we can encode Statement as CompactStatement, and anything as itself.

This resembles codec::EncodeLike, but it’s distinct: EncodeLike is a marker trait which asserts at the typesystem level that one type’s encoding is a valid encoding for another type. It doesn’t perform any type conversion when encoding.

This trait, on the other hand, provides a method which can be used to simultaneously convert and encode one type as another.

Required Methods§

source

fn encode_as(&self) -> Vec<u8>

Convert Self into T, then encode T.

This is useful when T is a subset of Self, reducing encoding costs; its signature also means that we do not need to clone Self in order to retain ownership, as we would if we were to do self.clone().into().encode().

Implementors§

source§

impl<T> EncodeAs<T> for T
where T: Encode,