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 ["neo_sendTransaction", "neo_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
use neo3::neo_clients::{HttpProvider, RwClient};
use url::Url;
async fn t() -> Result<(), Box<dyn std::error::Error>> {
let http = HttpProvider::new(Url::parse("http://localhost:8545").unwrap())?;
let ws = neo3::neo_clients::Ws::connect("ws://localhost:8545").await?;
let rw = RwClient::new(http, ws);
Ok(())
}
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> JsonRpcProvider for RwClient<Read, Write>where
Read: JsonRpcProvider + 'static,
<Read as JsonRpcProvider>::Error: Sync + Send + 'static + Display,
Write: JsonRpcProvider + 'static,
<Write as JsonRpcProvider>::Error: Sync + Send + 'static + Display,
impl<Read, Write> JsonRpcProvider for RwClient<Read, Write>where
Read: JsonRpcProvider + 'static,
<Read as JsonRpcProvider>::Error: Sync + Send + 'static + Display,
Write: JsonRpcProvider + 'static,
<Write as JsonRpcProvider>::Error: Sync + Send + 'static + Display,
Source§fn fetch<'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 fetch<'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
Source§type Error = RwClientError<Read, Write>
type Error = RwClientError<Read, Write>
A JSON-RPC Error
Auto Trait Implementations§
impl<Read, Write> Freeze for RwClient<Read, Write>
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more