pub trait DynArgInput {
    type ItemInput: TopDecodeInput;
    type ErrorApi: ErrorApi + ManagedTypeApi + Sized;

    // Required methods
    fn dyn_arg_vm_api(&self) -> Self::ErrorApi;
    fn has_next(&self) -> bool;
    fn next_arg_input(&mut self) -> Self::ItemInput;

    // Provided methods
    fn vm_api_cast<CastApi: Clone + 'static>(&self) -> CastApi { ... }
    fn assert_no_more_args(&self) { ... }
    fn flush_ignore(&mut self) { ... }
}
Expand description

Abstracts away the loading of multi-arguments. Acts as an abstract source for these arguments.

The main method, next_arg_input will provide a decode input, from which any deserializable object can be deserialized.

Structs implementing this trait are also responsible with error handling, such as:

  • deserialization errors
  • insufficient arguments
  • too many arguments For this reason it also requires the ErrorApi trait.

There are 2 main scenarios for it:

  • deserializing endpoint arguments directly from the API
  • deserializing callback arguments saved to storage, from a call data string

Required Associated Types§

Required Methods§

source

fn dyn_arg_vm_api(&self) -> Self::ErrorApi

source

fn has_next(&self) -> bool

Check if there are more arguments that can be loaded.

source

fn next_arg_input(&mut self) -> Self::ItemInput

Retrieves an input for deserializing an argument. If the loader is out of arguments, it will crash by itself with an appropriate error, without returning. Use if the next argument is optional, use has_next beforehand.

Provided Methods§

source

fn vm_api_cast<CastApi: Clone + 'static>(&self) -> CastApi

source

fn assert_no_more_args(&self)

Called after retrieving all arguments to validate that extra arguments were not provided.

source

fn flush_ignore(&mut self)

Consumes all inputs and ignores them. After executing this, assert_no_more_args should not fail.

Object Safety§

This trait is not object safe.

Implementors§