pub struct Client { /* private fields */ }
Expand description
A JSON-RPC client.
Creates a new Client using one of the transport-specific constructors e.g.,
Client::simple_http
for a bare-minimum HTTP transport.
Implementations§
source§impl Client
impl Client
sourcepub fn with_transport<T: Transport>(transport: T) -> Client
pub fn with_transport<T: Transport>(transport: T) -> Client
Creates a new client with the given transport.
sourcepub fn build_request<'a>(
&self,
method: &'a str,
params: Option<&'a RawValue>
) -> Request<'a>
pub fn build_request<'a>( &self, method: &'a str, params: Option<&'a RawValue> ) -> Request<'a>
Builds a request.
To construct the arguments, one can use one of the shorthand methods
crate::arg
or crate::try_arg
.
sourcepub fn send_request(&self, request: Request<'_>) -> Result<Response, Error>
pub fn send_request(&self, request: Request<'_>) -> Result<Response, Error>
Sends a request to a client.
sourcepub fn send_batch(
&self,
requests: &[Request<'_>]
) -> Result<Vec<Option<Response>>, Error>
pub fn send_batch( &self, requests: &[Request<'_>] ) -> Result<Vec<Option<Response>>, Error>
Sends a batch of requests to the client.
Note that the requests need to have valid IDs, so it is advised to create the requests
with Client::build_request
.
Returns
The return vector holds the response for the request at the corresponding index. If no
response was provided, it’s None
.
sourcepub fn call<R: for<'a> Deserialize<'a>>(
&self,
method: &str,
args: Option<&RawValue>
) -> Result<R, Error>
pub fn call<R: for<'a> Deserialize<'a>>( &self, method: &str, args: Option<&RawValue> ) -> Result<R, Error>
Makes a request and deserializes the response.
To construct the arguments, one can use one of the shorthand methods
crate::arg
or crate::try_arg
.