pub trait EncodeAs<T> {
    fn encode_as(&self) -> Vec<u8, Global> ;
}
Expand description

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

This resembles parity_scale_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§

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§