diff options
Diffstat (limited to 'crates/gen_lsp_server/src/msg.rs')
-rw-r--r-- | crates/gen_lsp_server/src/msg.rs | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/crates/gen_lsp_server/src/msg.rs b/crates/gen_lsp_server/src/msg.rs index 533d7da3e..d2ce20a11 100644 --- a/crates/gen_lsp_server/src/msg.rs +++ b/crates/gen_lsp_server/src/msg.rs | |||
@@ -87,6 +87,17 @@ impl RawMessage { | |||
87 | } | 87 | } |
88 | 88 | ||
89 | impl RawRequest { | 89 | impl RawRequest { |
90 | pub fn new<R>(id: u64, params: R::Params) -> RawRequest | ||
91 | where | ||
92 | R: Request, | ||
93 | R::Params: Serialize, | ||
94 | { | ||
95 | RawRequest { | ||
96 | id: id, | ||
97 | method: R::METHOD.to_string(), | ||
98 | params: to_value(¶ms).unwrap(), | ||
99 | } | ||
100 | } | ||
90 | pub fn cast<R>(self) -> ::std::result::Result<(u64, R::Params), RawRequest> | 101 | pub fn cast<R>(self) -> ::std::result::Result<(u64, R::Params), RawRequest> |
91 | where | 102 | where |
92 | R: Request, | 103 | R: Request, |
@@ -102,7 +113,10 @@ impl RawRequest { | |||
102 | } | 113 | } |
103 | 114 | ||
104 | impl RawResponse { | 115 | impl RawResponse { |
105 | pub fn ok(id: u64, result: impl Serialize) -> RawResponse { | 116 | pub fn ok<R>(id: u64, result: R::Result) -> RawResponse |
117 | where R: Request, | ||
118 | R::Result: Serialize, | ||
119 | { | ||
106 | RawResponse { | 120 | RawResponse { |
107 | id, | 121 | id, |
108 | result: Some(to_value(&result).unwrap()), | 122 | result: Some(to_value(&result).unwrap()), |