Trait duniter::service::client::ExecuteWithClient

source ·
pub trait ExecuteWithClient {
    type Output;

    // Required method
    fn execute_with_client<Client, Api, Backend>(
        self,
        client: Arc<Client>,
    ) -> Self::Output
       where Backend: Backend<Block> + 'static,
             Backend::State: StateBackend<BlakeTwo256>,
             Api: RuntimeApiCollection,
             Client: AbstractClient<Block, Backend, Api = Api> + 'static;
}
Expand description

Execute something with the client instance.

As there exist multiple chains, like g1 itself, gtest, gdev etc, there can exist different kinds of client types. As these client types differ in the generics that are being used, we can not easily return them from a function. For returning them from a function there exists Client. However, the problem on how to use this client instance still exists. This trait “solves” it in a dirty way. It requires a type to implement this trait and than the execute_with_client function can be called with any possible client instance.

In a perfect world, we could make a closure work in this way.

Required Associated Types§

source

type Output

The return type when calling this instance.

Required Methods§

source

fn execute_with_client<Client, Api, Backend>( self, client: Arc<Client>, ) -> Self::Output
where Backend: Backend<Block> + 'static, Backend::State: StateBackend<BlakeTwo256>, Api: RuntimeApiCollection, Client: AbstractClient<Block, Backend, Api = Api> + 'static,

Execute whatever should be executed with the given client instance.

Object Safety§

This trait is not object safe.

Implementors§