Skip to content

Commit 44e0488

Browse files
committed
lsps: Add additional documentation
Adds some additional documentation to the json-rpc v2.0 messages and error types. Signed-off-by: Peter Neuroth <[email protected]>
1 parent 653dc4c commit 44e0488

File tree

1 file changed

+17
-2
lines changed
  • plugins/lsps-plugin/src/jsonrpc

1 file changed

+17
-2
lines changed

plugins/lsps-plugin/src/jsonrpc/mod.rs

+17-2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ const METHOD_NOT_FOUND: i64 = -32601;
1313
const INVALID_PARAMS: i64 = -32602;
1414
const INTERNAL_ERROR: i64 = -32603;
1515

16+
/// Error type for JSON-RPC related operations.
17+
///
18+
/// Encapsulates various error conditions that may occur during JSON-RPC
19+
/// operations, including serialization errors, transport issues, and
20+
/// protocol-specific errors.
1621
#[derive(Error, Debug)]
1722
pub enum Error {
1823
#[error("JSON error: {0}")]
@@ -31,6 +36,8 @@ impl Error {
3136
}
3237
}
3338

39+
/// Transport-specific errors that may occur when sending or receiving JSON-RPC
40+
/// messages.
3441
#[derive(Error, Debug)]
3542
pub enum TransportError {
3643
#[error("Timeout")]
@@ -39,9 +46,14 @@ pub enum TransportError {
3946
Other(String),
4047
}
4148

49+
/// Convenience type alias for Result with the JSON-RPC Error type.
4250
pub type Result<T> = std::result::Result<T, Error>;
4351

44-
/// Trait to convert a struct into a JSON-RPC RequestObject.
52+
/// Trait for types that can be converted into JSON-RPC request objects.
53+
///
54+
/// Implementing this trait allows a struct to be used as a typed JSON-RPC
55+
/// request, with an associated method name and automatic conversion to the
56+
/// request format.
4557
pub trait JsonRpcRequest: Serialize {
4658
const METHOD: &'static str;
4759
fn into_request(self, id: impl Into<Option<String>>) -> RequestObject<Self>
@@ -57,7 +69,10 @@ pub trait JsonRpcRequest: Serialize {
5769
}
5870
}
5971

60-
/// Trait for converting JSON-RPC responses into typed results.
72+
/// Trait for types that can be converted from JSON-RPC response objects.
73+
///
74+
/// This trait provides methods for converting between typed response objects
75+
/// and JSON-RPC protocol response envelopes.
6176
pub trait JsonRpcResponse<T>
6277
where
6378
T: DeserializeOwned,

0 commit comments

Comments
 (0)