Trait scale_encode::EncodeAsType 
source · pub trait EncodeAsType {
    // Required method
    fn encode_as_type_to(
        &self,
        type_id: u32,
        types: &PortableRegistry,
        out: &mut Vec<u8>
    ) -> Result<(), Error>;
    // Provided method
    fn encode_as_type(
        &self,
        type_id: u32,
        types: &PortableRegistry
    ) -> 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§
sourcefn encode_as_type_to(
    &self,
    type_id: u32,
    types: &PortableRegistry,
    out: &mut Vec<u8>
) -> Result<(), Error>
 
fn encode_as_type_to( &self, type_id: u32, types: &PortableRegistry, out: &mut Vec<u8> ) -> Result<(), Error>
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§
sourcefn encode_as_type(
    &self,
    type_id: u32,
    types: &PortableRegistry
) -> Result<Vec<u8>, Error>
 
fn encode_as_type( &self, type_id: u32, types: &PortableRegistry ) -> Result<Vec<u8>, Error>
This is a helper function which internally calls EncodeAsType::encode_as_type_to. Prefer to
implement that instead.