EncodableValues

Trait EncodableValues 

Source
pub trait EncodableValues {
    // Required method
    fn encode_next_value_to<Resolver>(
        &mut self,
        type_id: Resolver::TypeId,
        types: &Resolver,
        out: &mut Vec<u8>,
    ) -> Result<(), Error>
       where Resolver: TypeResolver;

    // Provided method
    fn encode_next_value<Resolver>(
        &mut self,
        type_id: Resolver::TypeId,
        types: &Resolver,
    ) -> Result<Vec<u8>, Error>
       where Resolver: TypeResolver { ... }
}
Expand description

Since scale_encode::EncodeAsType is not dyn safe, this trait is used to iterate through and encode a set of values.

Required Methods§

Source

fn encode_next_value_to<Resolver>( &mut self, type_id: Resolver::TypeId, types: &Resolver, out: &mut Vec<u8>, ) -> Result<(), Error>
where Resolver: TypeResolver,

Encode the next value, if there is one, into the provided output buffer. This method must not be called more times than IntoEncodableValues::num_encodable_values.

§Panics

This method may panic if we call it more than IntoEncodableValues::num_encodable_values times (ie we try to encode more values than actually exist).

Provided Methods§

Source

fn encode_next_value<Resolver>( &mut self, type_id: Resolver::TypeId, types: &Resolver, ) -> Result<Vec<u8>, Error>
where Resolver: TypeResolver,

Encode the next value, if there is one, and return the encoded bytes. This method must not be called more times than IntoEncodableValues::num_encodable_values.

§Panics

This method may panic if we call it more than IntoEncodableValues::num_encodable_values times (ie we try to encode more values than actually exist).

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl EncodableValues for ()

Source§

fn encode_next_value_to<Resolver>( &mut self, _type_id: Resolver::TypeId, _types: &Resolver, _out: &mut Vec<u8>, ) -> Result<(), Error>
where Resolver: TypeResolver,

Source§

impl<'a, K: EncodeAsType> EncodableValues for Iter<'a, K>

Source§

fn encode_next_value_to<Resolver>( &mut self, type_id: Resolver::TypeId, types: &Resolver, out: &mut Vec<u8>, ) -> Result<(), Error>
where Resolver: TypeResolver,

Implementors§