@@ -13,6 +13,11 @@ const METHOD_NOT_FOUND: i64 = -32601;
1313const INVALID_PARAMS : i64 = -32602 ;
1414const 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 ) ]
1722pub 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 ) ]
3542pub 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.
4250pub 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.
4557pub 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.
6176pub trait JsonRpcResponse < T >
6277where
6378 T : DeserializeOwned ,
0 commit comments