| 1058 | S: Send + Clone, |
| 1059 | { |
| 1060 | pub async fn send_custom_notification( |
| 1061 | &self, |
| 1062 | method: String, |
| 1063 | v: serde_json::Value, |
| 1064 | ) -> Result<(), Error> { |
| 1065 | // Modern has them inside object of same name. |
| 1066 | // This is deprecated, scheduled for removal 26.09. |
| 1067 | let mut params = match &v { |
| 1068 | serde_json::Value::Object(map) => map.clone(), |
| 1069 | _ => return Err(anyhow::anyhow!("params must be a JSON object")), |
| 1070 | }; |
| 1071 | params.insert(method.clone(), json!(v)); |
| 1072 | |
| 1073 | self.sender |
| 1074 | .send(json!({ |
| 1075 | "jsonrpc": "2.0", |
| 1076 | "method": method, |
| 1077 | "params": params, |
| 1078 | })) |
| 1079 | .await |
| 1080 | .context("sending custom notification")?; |
| 1081 | Ok(()) |
| 1082 | } |
| 1083 | |
| 1084 | /// Wait for plugin shutdown |
| 1085 | pub async fn join(&self) -> Result<(), Error> { |