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
sourceimpl<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
Trait Implementations
sourceimpl<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,
sourcefn 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
Auto Trait Implementations
impl<Read, Write> RefUnwindSafe for RwClient<Read, Write> where
Read: RefUnwindSafe,
Write: RefUnwindSafe,
impl<Read, Write> Send for RwClient<Read, Write> where
Read: Send,
Write: Send,
impl<Read, Write> Sync for RwClient<Read, Write> where
Read: Sync,
Write: Sync,
impl<Read, Write> Unpin for RwClient<Read, Write> where
Read: Unpin,
Write: Unpin,
impl<Read, Write> UnwindSafe for RwClient<Read, Write> where
Read: UnwindSafe,
Write: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Instruments this type with the provided Span, returning an
Instrumented wrapper. Read more
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into)Uses borrowed data to replace owned data, usually by cloning. Read more
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
fn vzip(self) -> V
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber to this type, returning a
WithDispatch wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber to this type, returning a
WithDispatch wrapper. Read more