ethers-rs/crates/ethers-providers/src/lib.rs

31 lines
834 B
Rust
Raw Normal View History

2020-05-26 09:52:15 +00:00
//! Ethereum compatible providers
//! Currently supported:
//! - Raw HTTP POST requests
//!
//! TODO: WebSockets, multiple backends, popular APIs etc.
mod http;
2020-05-26 10:24:19 +00:00
mod provider;
2020-05-26 09:52:15 +00:00
use async_trait::async_trait;
use serde::{Deserialize, Serialize};
use std::{error::Error, fmt::Debug};
2020-05-26 10:24:19 +00:00
pub use provider::Provider;
2020-05-26 09:52:15 +00:00
/// An HTTP provider for interacting with an Ethereum-compatible blockchain
pub type HttpProvider = Provider<http::Provider>;
#[async_trait]
/// Implement this trait in order to plug in different backends
pub trait JsonRpcClient: Debug {
type Error: Error;
/// Sends a request with the provided method and the params serialized as JSON
async fn request<T: Serialize + Send + Sync, R: for<'a> Deserialize<'a>>(
&self,
method: &str,
params: Option<T>,
) -> Result<R, Self::Error>;
2020-05-26 09:37:31 +00:00
}