Trait moonbeam_service::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>,
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 inside Moonbeam, like Moonbeam itself, Moonbase,
Moonriver 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
](ExecuteWithClient:
: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§
Required Methods§
sourcefn execute_with_client<Client, Api, Backend>(
self,
client: Arc<Client>,
) -> Self::Outputwhere
Backend: Backend<Block>,
Backend::State: StateBackend<BlakeTwo256>,
Api: RuntimeApiCollection,
Client: AbstractClient<Block, Backend, Api = Api> + 'static,
fn execute_with_client<Client, Api, Backend>(
self,
client: Arc<Client>,
) -> Self::Outputwhere
Backend: Backend<Block>,
Backend::State: StateBackend<BlakeTwo256>,
Api: RuntimeApiCollection,
Client: AbstractClient<Block, Backend, Api = Api> + 'static,
Execute whatever should be executed with the given client instance.