Struct jsonrpc::client::Client

source ·
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

source

pub fn with_transport<T: Transport>(transport: T) -> Client

Creates a new client with the given transport.

source

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.

source

pub fn send_request(&self, request: Request<'_>) -> Result<Response, Error>

Sends a request to a client.

source

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.

source

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.

source§

impl Client

source

pub fn simple_http( url: &str, user: Option<String>, pass: Option<String> ) -> Result<Client, Error>

Available on crate feature simple_http only.

Creates a new JSON-RPC client using a bare-minimum HTTP transport.

source

pub fn http_proxy( url: &str, user: Option<String>, pass: Option<String>, proxy_addr: &str, proxy_auth: Option<(&str, &str)> ) -> Result<Client, Error>

Available on crate features simple_http and proxy only.

Creates a new JSON_RPC client using a HTTP-Socks5 proxy transport.

Trait Implementations§

source§

impl Debug for Client

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<T: Transport> From<T> for Client

source§

fn from(t: T) -> Client

Converts to this type from the input type.

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> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.