aboutsummaryrefslogtreecommitdiff
path: root/jsonrpc/src/message.rs
diff options
context:
space:
mode:
Diffstat (limited to 'jsonrpc/src/message.rs')
-rw-r--r--jsonrpc/src/message.rs36
1 files changed, 22 insertions, 14 deletions
diff --git a/jsonrpc/src/message.rs b/jsonrpc/src/message.rs
index f4bf490..9c89362 100644
--- a/jsonrpc/src/message.rs
+++ b/jsonrpc/src/message.rs
@@ -23,9 +23,12 @@ pub struct Request {
pub method: String,
pub params: serde_json::Value,
pub id: serde_json::Value,
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub subscriber: Option<serde_json::Value>,
}
#[derive(Debug, Serialize, Deserialize)]
+#[serde(deny_unknown_fields)]
pub struct Response {
pub jsonrpc: String,
#[serde(skip_serializing_if = "Option::is_none")]
@@ -34,30 +37,35 @@ pub struct Response {
pub error: Option<Error>,
#[serde(skip_serializing_if = "Option::is_none")]
pub id: Option<serde_json::Value>,
-}
-
-#[derive(Debug, Serialize, Deserialize)]
-pub struct Error {
- pub code: i32,
- pub message: String,
#[serde(skip_serializing_if = "Option::is_none")]
- pub data: Option<serde_json::Value>,
+ pub subscription: Option<serde_json::Value>,
}
#[derive(Debug, Serialize, Deserialize)]
pub struct Notification {
pub jsonrpc: String,
- pub method: String,
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub method: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub params: Option<serde_json::Value>,
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub subscription: Option<serde_json::Value>,
+}
+
+#[derive(Debug, Serialize, Deserialize)]
+pub struct Error {
+ pub code: i32,
+ pub message: String,
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub data: Option<serde_json::Value>,
}
impl std::fmt::Display for Request {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(
f,
- "{{jsonrpc: {}, method: {}, params: {:?}, id: {:?}}}",
- self.jsonrpc, self.method, self.params, self.id
+ "{{jsonrpc: {}, method: {}, params: {:?}, id: {:?}, subscribe: {:?}}}",
+ self.jsonrpc, self.method, self.params, self.id, self.subscriber
)
}
}
@@ -66,8 +74,8 @@ impl std::fmt::Display for Response {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(
f,
- "{{jsonrpc: {}, result': {:?}, error: {:?} , id: {:?}}}",
- self.jsonrpc, self.result, self.error, self.id
+ "{{jsonrpc: {}, result': {:?}, error: {:?} , id: {:?}, subscription: {:?}}}",
+ self.jsonrpc, self.result, self.error, self.id, self.subscription
)
}
}
@@ -86,8 +94,8 @@ impl std::fmt::Display for Notification {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(
f,
- "{{jsonrpc: {}, method: {}, params: {:?}}}",
- self.jsonrpc, self.method, self.params
+ "{{jsonrpc: {}, method: {:?}, params: {:?}, subscription: {:?}}}",
+ self.jsonrpc, self.method, self.params, self.subscription
)
}
}