Struct ethers_providers::RwClient
source · pub struct RwClient<Read, Write> { /* private fields */ }
Expand description
A client contains two clients.
One is used for read operations
One is used for write operations that consume gas ["eth_sendTransaction", "eth_sendRawTransaction"]
Note: if the method is unknown this client falls back to the read client
Implementations§
source§impl<Read, Write> RwClient<Read, Write>
impl<Read, Write> RwClient<Read, Write>
sourcepub fn new(r: Read, w: Write) -> RwClient<Read, Write>
pub fn new(r: Read, w: Write) -> RwClient<Read, Write>
Creates a new client using two different clients
Example
async fn t(){
use ethers_providers::{Http, RwClient, Ws};
let http = Http::new(Url::parse("http://localhost:8545").unwrap());
let ws = Ws::connect("ws://localhost:8545").await.unwrap();
let rw = RwClient::new(http, ws);
sourcepub fn read_client(&self) -> &Read
pub fn read_client(&self) -> &Read
Returns the client used for read operations
sourcepub fn write_client(&self) -> &Write
pub fn write_client(&self) -> &Write
Returns the client used for read operations
sourcepub fn split(self) -> (Read, Write)
pub fn split(self) -> (Read, Write)
Consumes the client and returns the underlying clients
Trait Implementations§
source§impl<Read, Write> JsonRpcClient for RwClient<Read, Write>where
Read: JsonRpcClient + 'static,
<Read as JsonRpcClient>::Error: Sync + Send + 'static,
Write: JsonRpcClient + 'static,
<Write as JsonRpcClient>::Error: Sync + Send + 'static,
impl<Read, Write> JsonRpcClient for RwClient<Read, Write>where
Read: JsonRpcClient + 'static,
<Read as JsonRpcClient>::Error: Sync + Send + 'static,
Write: JsonRpcClient + 'static,
<Write as JsonRpcClient>::Error: Sync + Send + 'static,
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,
R: DeserializeOwned,
T: 'async_trait + Serialize + Send + Sync,
R: 'async_trait + DeserializeOwned,
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
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,
R: DeserializeOwned,
T: 'async_trait + Serialize + Send + Sync,
R: 'async_trait + DeserializeOwned,
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
Sends a POST request with the provided method and the params serialized as JSON over HTTP
§type Error = RwClientError<Read, Write>
type Error = RwClientError<Read, Write>
A JSON-RPC Error