aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--jsonrpc/src/client.rs2
-rw-r--r--jsonrpc/src/codec.rs2
-rw-r--r--jsonrpc/src/lib.rs10
3 files changed, 11 insertions, 3 deletions
diff --git a/jsonrpc/src/client.rs b/jsonrpc/src/client.rs
index dc36c0d..efbaf50 100644
--- a/jsonrpc/src/client.rs
+++ b/jsonrpc/src/client.rs
@@ -54,7 +54,7 @@ impl Client {
let mut buffer = vec![];
if let Some(t) = self.config.timeout {
- self.codec.read_until_timeout(&mut buffer, t).await?;
+ self.codec.read_until_with_timeout(&mut buffer, t).await?;
} else {
self.codec.read_until(&mut buffer).await?;
};
diff --git a/jsonrpc/src/codec.rs b/jsonrpc/src/codec.rs
index 451cdb4..4a70412 100644
--- a/jsonrpc/src/codec.rs
+++ b/jsonrpc/src/codec.rs
@@ -94,7 +94,7 @@ impl Codec {
Ok(())
}
- pub async fn read_until_timeout(&self, buffer: &mut Vec<u8>, t: u64) -> Result<usize> {
+ pub async fn read_until_with_timeout(&self, buffer: &mut Vec<u8>, t: u64) -> Result<usize> {
timeout(std::time::Duration::from_secs(t), self.read_until(buffer)).await?
}
}
diff --git a/jsonrpc/src/lib.rs b/jsonrpc/src/lib.rs
index df66363..3e0eb8f 100644
--- a/jsonrpc/src/lib.rs
+++ b/jsonrpc/src/lib.rs
@@ -18,6 +18,14 @@
//! let msg: String = serde_json::from_value(params)?;
//! Ok(serde_json::json!(format!("Hello {msg}!")))
//! }
+//!
+//! async fn foo(&self, params: Value) -> Result<Value, JsonRPCError> {
+//! Ok(serde_json::json!("foo!"))
+//! }
+//!
+//! async fn bar(&self, params: Value) -> Result<Value, JsonRPCError> {
+//! Ok(serde_json::json!("bar!"))
+//! }
//! }
//!
//! // Server
@@ -30,7 +38,7 @@
//! let server = Server::new(listener, config, ex.clone());
//!
//! // Register the HelloWorld service
-//! register_service!(HelloWorld, say_hello);
+//! register_service!(HelloWorld, say_hello, foo, bar);
//! server.attach_service(HelloWorld{});
//!
//! // Starts the server