pub struct Client { /* private fields */ }
Expand description
A JSON-RPC client.
Create a new Client using one of the transport-specific constructors:
- Client::simple_http for the built-in 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: &'a [Box<RawValue>],
) -> Request<'a>
pub fn build_request<'a>( &self, method: &'a str, params: &'a [Box<RawValue>], ) -> Request<'a>
Builds a request.
To construct the arguments, one can use one of the shorthand methods [jsonrpc::arg] or [jsonrpc::try_arg].
Sourcepub async fn send_request(
&self,
request: Request<'_>,
) -> Result<Response, Error>
pub async fn send_request( &self, request: Request<'_>, ) -> Result<Response, Error>
Sends a request to a client
Sourcepub async fn send_batch(
&self,
requests: &[Request<'_>],
) -> Result<Vec<Option<Response>>, Error>
pub async fn send_batch( &self, requests: &[Request<'_>], ) -> Result<Vec<Option<Response>>, Error>
Sends a batch of requests to the client. The return vector holds the response for the request at the corresponding index. If no response was provided, it’s None.
Note that the requests need to have valid IDs, so it is advised to create the requests with [build_request].
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for Client
impl !RefUnwindSafe for Client
impl Send for Client
impl Sync for Client
impl Unpin for Client
impl !UnwindSafe for Client
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