Explorar o código

rpcclient: add close connection function

ghassmo %!s(int64=4) %!d(string=hai) anos
pai
achega
e16204496b
Modificáronse 1 ficheiros con 5 adicións e 0 borrados
  1. 5 0
      src/rpc/rpcclient.rs

+ 5 - 0
src/rpc/rpcclient.rs

@@ -18,6 +18,11 @@ impl RpcClient {
         Ok(Self { sender, receiver, stop_signal })
     }
 
+    pub async fn close(&self) -> Result<()> {
+        self.stop_signal.send(()).await?;
+        Ok(())
+    }
+
     pub async fn request(&self, value: JsonRequest) -> Result<Value> {
         let req_id = value.id.clone().as_u64().unwrap_or(0);
         let value = json!(value);