@@ -13,6 +13,11 @@ const METHOD_NOT_FOUND: i64 = -32601;
13
13
const INVALID_PARAMS : i64 = -32602 ;
14
14
const INTERNAL_ERROR : i64 = -32603 ;
15
15
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.
16
21
#[ derive( Error , Debug ) ]
17
22
pub enum Error {
18
23
#[ error( "JSON error: {0}" ) ]
@@ -31,6 +36,8 @@ impl Error {
31
36
}
32
37
}
33
38
39
+ /// Transport-specific errors that may occur when sending or receiving JSON-RPC
40
+ /// messages.
34
41
#[ derive( Error , Debug ) ]
35
42
pub enum TransportError {
36
43
#[ error( "Timeout" ) ]
@@ -39,9 +46,14 @@ pub enum TransportError {
39
46
Other ( String ) ,
40
47
}
41
48
49
+ /// Convenience type alias for Result with the JSON-RPC Error type.
42
50
pub type Result < T > = std:: result:: Result < T , Error > ;
43
51
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.
45
57
pub trait JsonRpcRequest : Serialize {
46
58
const METHOD : & ' static str ;
47
59
fn into_request ( self , id : impl Into < Option < String > > ) -> RequestObject < Self >
@@ -57,7 +69,10 @@ pub trait JsonRpcRequest: Serialize {
57
69
}
58
70
}
59
71
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.
61
76
pub trait JsonRpcResponse < T >
62
77
where
63
78
T : DeserializeOwned ,
0 commit comments