Trait scale_encode::EncodeAsFields
source · pub trait EncodeAsFields {
// Required method
fn encode_as_fields_to<R: TypeResolver>(
&self,
fields: &mut dyn FieldIter<'_, R::TypeId>,
types: &R,
out: &mut Vec<u8>
) -> Result<(), Error>;
// Provided method
fn encode_as_fields<R: TypeResolver>(
&self,
fields: &mut dyn FieldIter<'_, R::TypeId>,
types: &R
) -> Result<Vec<u8>, Error> { ... }
}
Expand description
This is similar to EncodeAsType
, except that it can be implemented on types that can be encoded
to bytes given a list of fields instead of a single type ID. This is generally implemented just for
tuple and struct types, and is automatically implemented via the EncodeAsType
macro.
Required Methods§
Provided Methods§
sourcefn encode_as_fields<R: TypeResolver>(
&self,
fields: &mut dyn FieldIter<'_, R::TypeId>,
types: &R
) -> Result<Vec<u8>, Error>
fn encode_as_fields<R: TypeResolver>( &self, fields: &mut dyn FieldIter<'_, R::TypeId>, types: &R ) -> Result<Vec<u8>, Error>
This is a helper function which internally calls EncodeAsFields::encode_as_fields_to
. Prefer to
implement that instead.
Object Safety§
This trait is not object safe.