Module helpers

Module helpers 

Source
Expand description

Helper functions and types to assist with decoding.

  • type_registry_from_metadata is expected to be used when decoding things from historic runtimes, adding the ability to decode some types from information in the metadata.
  • decode_with_error_tracing is like decode_with_visitor, but will use a tracing visitor (if the error-tracing feature is enabled) to provide more information in the event that decoding fails.

Re-exports§

pub use scale_decode;

Structs§

DecodeErrorTrace
A tracing decode error.

Enums§

Entry
This represents either an entry name, or the name of the thing that the entry is in (for instance the name of a pallet or of a Runtime API trait).

Traits§

DecodableValues
Implementors of this trait are capable of decoding multiple values from bytes into an output type such as a tuple or fixed size array.
EncodableValues
Since scale_encode::EncodeAsType is not dyn safe, this trait is used to iterate through and encode a set of values.
IntoDecodableValues
This can be implemented for any type that can be decoded into in multiple steps via scale_decode::DecodeAsType. The common use case is to decode some sets of bytes into a tuple of multiple types, step by step. As well as tuples up to size 12, Implementations also exist and arrays.
IntoEncodableValues
This can be implemented for anything that can be encoded in multiple steps into a set of values via scale_encode::EncodeAsType. The common use case is to encode a tuple of multiple types, step by step, into bytes. As well as tuples up to size 12, Implementations also exist for Vecs and arrays.

Functions§

decode_with_error_tracing
Decode some bytes given a type ID and type resolver, and a visitor which decides the output value.
decode_with_visitor
An alias to scale_decode::visitor::decode_with_visitor. This can be used to decode the byte ranges given back from functions like crate::extrinsics::decode_extrinsic or crate::storage::decode_storage_key. Decode data according to the type ID and type resolver provided. The provided pointer to the data slice will be moved forwards as needed depending on what was decoded, and a method on the provided Visitor will be called depending on the type that needs to be decoded.
type_registry_from_metadata
frame_metadata::RuntimeMetadata contains information about runtime calls and events. This function adds this information into a scale_info_legacy::TypeRegistry which can then be referenced by other types. The main types you’ll be able to reference from this set are:
type_registry_from_metadata_any
This is like type_registry_from_metadata, except it can be handed the outer frame_metadata::RuntimeMetadata enum and will extract types from it where appropriate (handing back no types for deprecated or modern metadata).