Payload

Trait Payload 

Source
pub trait Payload {
    type ReturnType: DecodeWithMetadata;

    // Required methods
    fn query_id(&self) -> &[u8; 32];
    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 View Function payload that can call into the runtime of node.

§Components

  • associated return type

Resulting bytes of the call are interpreted into this type.

  • query ID

The ID used to identify in the runtime which view function to call.

  • encoded arguments

Each argument of the View Function must be scale-encoded.

Required Associated Types§

Source

type ReturnType: DecodeWithMetadata

The return type of the function call.

Required Methods§

Source

fn query_id(&self) -> &[u8; 32]

The payload target.

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