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§
Sourcetype ReturnType: DecodeWithMetadata
type ReturnType: DecodeWithMetadata
The return type of the function call.
Required Methods§
Sourcefn trait_name(&self) -> &str
fn trait_name(&self) -> &str
The runtime API trait name.
Sourcefn method_name(&self) -> &str
fn method_name(&self) -> &str
The runtime API method name.
Provided Methods§
Sourcefn encode_args(&self, metadata: &Metadata) -> Result<Vec<u8>, Error>
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
.
Sourcefn validation_hash(&self) -> Option<[u8; 32]>
fn validation_hash(&self) -> Option<[u8; 32]>
Returns the statically generated validation hash.