Struct ethers_providers::RwClient
source · pub struct RwClient<Read, Write> { /* private fields */ }
Expand description
A client containing 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 write 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>>
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>>
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
Auto Trait Implementations§
impl<Read, Write> RefUnwindSafe for RwClient<Read, Write>where
Read: RefUnwindSafe,
Write: RefUnwindSafe,
impl<Read, Write> Send for RwClient<Read, Write>
impl<Read, Write> Sync for RwClient<Read, Write>
impl<Read, Write> Unpin for RwClient<Read, Write>
impl<Read, Write> UnwindSafe for RwClient<Read, Write>where
Read: UnwindSafe,
Write: UnwindSafe,
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more