44use {
55 crate :: domain:: { DecodingError , MessageId , SubscriptionId , Topic } ,
66 serde:: { de:: DeserializeOwned , Deserialize , Serialize } ,
7- std:: sync:: Arc ,
7+ std:: { fmt :: Debug , sync:: Arc } ,
88} ;
99
1010#[ cfg( test) ]
@@ -29,7 +29,7 @@ pub const MAX_FETCH_BATCH_SIZE: usize = 500;
2929type BoxError = Box < dyn std:: error:: Error + Send + Sync > ;
3030
3131/// Errors covering payload validation problems.
32- #[ derive( Debug , thiserror:: Error , PartialEq , Eq ) ]
32+ #[ derive( Debug , Clone , thiserror:: Error , PartialEq , Eq ) ]
3333pub enum ValidationError {
3434 #[ error( "Topic decoding failed: {0}" ) ]
3535 TopicDecoding ( DecodingError ) ,
@@ -109,14 +109,23 @@ where
109109 }
110110}
111111
112+ pub trait Serializable :
113+ Debug + Clone + PartialEq + Eq + Serialize + DeserializeOwned + Send + Sync + ' static
114+ {
115+ }
116+ impl < T > Serializable for T where
117+ T : Debug + Clone + PartialEq + Eq + Serialize + DeserializeOwned + Send + Sync + ' static
118+ {
119+ }
120+
112121/// Trait that adds validation capabilities and strong typing to errors and
113122/// successful responses. Implemented for all possible RPC request types.
114- pub trait RequestPayload {
123+ pub trait RequestPayload : Serializable {
115124 /// The error representing a failed request.
116- type Error : Into < ErrorData > ;
125+ type Error : Into < ErrorData > + Send + ' static ;
117126
118127 /// The type of a successful response.
119- type Response : Serialize + DeserializeOwned ;
128+ type Response : Serializable ;
120129
121130 /// Validates the request parameters.
122131 fn validate ( & self ) -> Result < ( ) , ValidationError > {
0 commit comments