csharp_language_server/
notification.rs1use serde::Serialize;
2
3#[derive(Serialize, Debug)]
4#[serde(untagged)]
5pub enum Params {
6 Solution(SolutionParams),
7 Project(ProjectParams),
8}
9
10#[derive(Serialize, Debug)]
11pub struct Notification {
12 pub jsonrpc: String,
13 pub method: String,
14 pub params: Params,
15}
16
17#[derive(Serialize, Debug)]
18pub struct SolutionParams {
19 pub solution: String,
20}
21
22#[derive(Serialize, Debug)]
23pub struct ProjectParams {
24 pub projects: Vec<String>,
25}
26
27impl Notification {
28 pub fn serialize(self) -> String {
29 let body = serde_json::to_string(&self).expect("Unable to serialize notification");
30 add_content_length_header(&body)
31 }
32}
33
34fn add_content_length_header(body: &str) -> String {
35 let header = format!("Content-Length: {}\r\n\r\n", body.len());
36 let full_message = format!("{header}{body}");
37
38 full_message
39}