Trait Payload

Source
pub trait Payload {
    type ReturnType: DecodeWithMetadata;

    // Required methods
    fn trait_name(&self) -> &str;
    fn method_name(&self) -> &str;
    fn encode_args_to(
        &self,
        metadata: &Metadata,
        out: &mut Vec<u8>,
    ) -> Result<(), Error>;

    // Provided methods
    fn encode_args(&self, metadata: &Metadata) -> Result<Vec<u8>, Error> { ... }
    fn validation_hash(&self) -> Option<[u8; 32]> { ... }
}
Expand description

This represents a runtime API payload that can call into the runtime of node.

§Components

  • associated return type

Resulting bytes of the call are interpreted into this type.

  • runtime function name

The function name of the runtime API call. This is obtained by concatenating the runtime trait name with the trait’s method.

For example, the substrate runtime trait Metadata contains the metadata_at_version function. The corresponding runtime function is Metadata_metadata_at_version.

  • encoded arguments

Each argument of the runtime function must be scale-encoded.

Required Associated Types§

Source

type ReturnType: DecodeWithMetadata

The return type of the function call.

Required Methods§

Source

fn trait_name(&self) -> &str

The runtime API trait name.

Source

fn method_name(&self) -> &str

The runtime API method name.

Source

fn encode_args_to( &self, metadata: &Metadata, out: &mut Vec<u8>, ) -> Result<(), Error>

Scale encode the arguments data.

Provided Methods§

Source

fn encode_args(&self, metadata: &Metadata) -> Result<Vec<u8>, Error>

Encode arguments data and return the output. This is a convenience wrapper around Payload::encode_args_to.

Source

fn validation_hash(&self) -> Option<[u8; 32]>

Returns the statically generated validation hash.

Implementors§

Source§

impl<ArgsData: EncodeAsFields, ReturnTy: DecodeWithMetadata> Payload for DefaultPayload<ArgsData, ReturnTy>

Source§

type ReturnType = ReturnTy