pub struct JsonRpcClient { /* private fields */ }Expand description
A JSON-RPC 2.0 client over HTTP POST. Request ids auto-increment per client.
Implementations§
Source§impl JsonRpcClient
impl JsonRpcClient
Sourcepub fn new(url: impl Into<String>) -> Self
pub fn new(url: impl Into<String>) -> Self
Creates a JSON-RPC client targeting the given URL using a fresh HTTP client.
Sourcepub fn with_client(url: impl Into<String>, http: Client) -> Self
pub fn with_client(url: impl Into<String>, http: Client) -> Self
Creates a JSON-RPC client targeting the given URL using the supplied HTTP client.
Sourcepub async fn call(&self, method: &str, params: Value) -> Result<Value>
pub async fn call(&self, method: &str, params: Value) -> Result<Value>
Invokes a JSON-RPC method and returns its result.
Returns Error::JsonRpc when the response carries an error member, or
Error::Http on a non-2xx transport response.
Trait Implementations§
Source§impl Clone for JsonRpcClient
impl Clone for JsonRpcClient
Source§fn clone(&self) -> JsonRpcClient
fn clone(&self) -> JsonRpcClient
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for JsonRpcClient
impl !UnwindSafe for JsonRpcClient
impl Freeze for JsonRpcClient
impl Send for JsonRpcClient
impl Sync for JsonRpcClient
impl Unpin for JsonRpcClient
impl UnsafeUnpin for JsonRpcClient
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