Derive Macro tetcore_subxt_proc_macro::Call[][src]

#[derive(Call)]

Derive macro that implements tetcore_subxt::Call for your struct and defines&implements the calls as an extension trait.

Use the Call derive macro in tandem with the #module macro to extend your struct to enable calls to tetcore and to decode events. The struct maps to the corresponding Tetcore runtime call, e.g.:

decl_module! {
    /* … */
    pub fn fun_stuff(origin, something: Vec<u8>) -> DispatchResult { /* … */ }
    /* … */
}

Implements tetcore_subxt::Call and adds an extension trait that provides two methods named as your struct.

Example:

pub struct MyRuntime;

impl System for MyRuntime { /* … */ }
impl Balances for MyRuntime { /* … */ }

#[module]
pub trait MyTrait: System + Balances {}

#[derive(Call)]
pub struct FunStuffCall<T: MyTrait> {
    /// Runtime marker.
    pub _runtime: PhantomData<T>,
    /// The argument passed to the call..
    pub something: Vec<u8>,
}

When building a Client parameterised to MyRuntime, you have access to two new methods: fun_stuff() and fun_stuff_and_watch() by way of the derived FunStuffExt trait. The _and_watch variant makes the call and waits for the result. The fields of the input struct become arguments to the calls (ignoring the marker field).

Under the hood the implementation calls submit() and watch() respectively.

N.B. You must use the #[derive(Call)] macro with #[module] in the same module or you will get errors about undefined method with a name starting with with_.