Trait JsonRpcClient

Source
pub trait JsonRpcClient {
    type Error: From<Error> + From<EthereumQueryError>;

    // Required methods
    fn request_inner<'life0, 'async_trait>(
        &'life0 self,
        payload: Vec<u8>,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, Self::Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn get_id<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = u64> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;

    // Provided method
    fn request<'life0, 'life1, 'async_trait, T, R>(
        &'life0 self,
        method: &'life1 str,
        params: T,
    ) -> Pin<Box<dyn Future<Output = Result<R, Self::Error>> + Send + 'async_trait>>
       where T: Debug + Serialize + Send + Sync + 'async_trait,
             R: DeserializeOwned + Send + 'async_trait,
             Self: Sync + 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
}
Expand description

A basic RPC client for making JSON queries

Required Associated Types§

Required Methods§

Source

fn request_inner<'life0, 'async_trait>( &'life0 self, payload: Vec<u8>, ) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

The inner function that has to be implemented and access the client

Source

fn get_id<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = u64> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Gets a new ID for the next message.

Provided Methods§

Source

fn request<'life0, 'life1, 'async_trait, T, R>( &'life0 self, method: &'life1 str, params: T, ) -> Pin<Box<dyn Future<Output = Result<R, Self::Error>> + Send + 'async_trait>>
where T: Debug + Serialize + Send + Sync + 'async_trait, R: DeserializeOwned + Send + 'async_trait, Self: Sync + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

The function doing the parsing of the input and output.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§