pub struct JsonRpcClient { /* private fields */ }Expand description
A JSON-RPC 2.0 client that communicates over line-delimited JSON on the stdin/stdout of a child process.
Implementations§
Source§impl JsonRpcClient
impl JsonRpcClient
Sourcepub fn new(stdin: ChildStdin, stdout: ChildStdout) -> Self
pub fn new(stdin: ChildStdin, stdout: ChildStdout) -> Self
Create a new client.
Spawns a background tokio task that reads line-delimited JSON from
stdout, routing responses to their pending futures and everything
else (notifications / incoming RPC calls) to an mpsc channel
retrievable via [take_incoming].
Sourcepub fn take_incoming(&mut self) -> Option<UnboundedReceiver<IncomingMessage>>
pub fn take_incoming(&mut self) -> Option<UnboundedReceiver<IncomingMessage>>
Take the receiver for incoming notifications and RPC calls.
This can only be called once — subsequent calls return None.
Sourcepub async fn request(
&self,
method: &str,
params: Option<Value>,
) -> Result<Response, Box<dyn Error + Send + Sync>>
pub async fn request( &self, method: &str, params: Option<Value>, ) -> Result<Response, Box<dyn Error + Send + Sync>>
Send a JSON-RPC request and wait for the matching response.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for JsonRpcClient
impl !RefUnwindSafe for JsonRpcClient
impl Send for JsonRpcClient
impl Sync for JsonRpcClient
impl Unpin for JsonRpcClient
impl UnsafeUnpin for JsonRpcClient
impl !UnwindSafe 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