aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_lsp_server/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_lsp_server/src/lib.rs')
-rw-r--r--crates/ra_lsp_server/src/lib.rs8
1 files changed, 8 insertions, 0 deletions
diff --git a/crates/ra_lsp_server/src/lib.rs b/crates/ra_lsp_server/src/lib.rs
index 1208c1343..a3464a5a3 100644
--- a/crates/ra_lsp_server/src/lib.rs
+++ b/crates/ra_lsp_server/src/lib.rs
@@ -31,6 +31,8 @@ mod config;
31mod world; 31mod world;
32mod diagnostics; 32mod diagnostics;
33 33
34use serde::de::DeserializeOwned;
35
34pub type Result<T> = std::result::Result<T, Box<dyn std::error::Error + Send + Sync>>; 36pub type Result<T> = std::result::Result<T, Box<dyn std::error::Error + Send + Sync>>;
35pub use crate::{ 37pub use crate::{
36 caps::server_capabilities, 38 caps::server_capabilities,
@@ -38,3 +40,9 @@ pub use crate::{
38 main_loop::LspError, 40 main_loop::LspError,
39 main_loop::{main_loop, show_message}, 41 main_loop::{main_loop, show_message},
40}; 42};
43
44pub fn from_json<T: DeserializeOwned>(what: &'static str, json: serde_json::Value) -> Result<T> {
45 let res = T::deserialize(&json)
46 .map_err(|e| format!("Failed to deserialize {}: {}; {}", what, e, json))?;
47 Ok(res)
48}