csskit_lsp/jsonrpc/
notification.rs

1use serde::{Deserialize, Serialize};
2use serde_json::{Value, to_value};
3
4/// A notification message. A processed notification message must not send a response back. They work like events.
5///
6/// As defined in [JSON-RPC](https://www.jsonrpc.org/specification#notification) and [LSP](https://microsoft.github.io/language-server-protocol/specifications/specification-3-16/#notificationMessage).
7#[derive(Debug, Clone, PartialEq, Eq, Hash, Deserialize, Serialize)]
8pub struct Notification {
9	pub method: String,
10	#[serde(default = "serde_json::Value::default", skip_serializing_if = "serde_json::Value::is_null")]
11	pub params: Value,
12}
13
14impl Notification {
15	pub fn new<T>(params: T::Params) -> Notification
16	where
17		T: lsp_types::request::Request,
18	{
19		Notification { method: T::METHOD.into(), params: to_value(params).unwrap() }
20	}
21}