pub trait EncodeAsType {
    fn encode_as_type_to(
        &self,
        type_id: u32,
        types: &PortableRegistry,
        context: Context,
        out: &mut Vec<u8>
    ) -> Result<(), Error>; fn encode_as_type(
        &self,
        type_id: u32,
        types: &PortableRegistry,
        context: Context
    ) -> Result<Vec<u8>, Error> { ... } }
Expand description

This trait signals that some static type can possibly be SCALE encoded given some type_id and PortableRegistry which dictates the expected encoding. A Context is also passed around, which is used internally to improve error reporting. Implementations should use the Context::at method to indicate the current location if they would like it to show up in error output.

Required Methods

Given some type_id, types, a context and some output target for the SCALE encoded bytes, attempt to SCALE encode the current value into the type given by type_id.

Provided Methods

This is a helper function which internally calls EncodeAsType::encode_as_type_to. Prefer to implement that instead.

Implementations on Foreign Types

Implementors