@@ -72,10 +72,41 @@ macro_rules! metadata {
72
72
73
73
#[ macro_export]
74
74
macro_rules! build_rpc_trait {
75
+ (
76
+ $( #[ $t_attr: meta] ) *
77
+ pub trait $name: ident $( <$( $generics: ident ) ,* >
78
+ $(
79
+ where
80
+ $( $generics2: ident : $bounds: tt $( + $morebounds: tt ) * , ) +
81
+ ) * ) *
82
+ {
83
+ $( $rest: tt ) +
84
+ }
85
+ ) => {
86
+ build_rpc_trait! {
87
+ @WITH_BOUNDS
88
+ $( #[ $t_attr] ) *
89
+ pub trait $name $( <
90
+ // first generic parameters with both bounds
91
+ $( $generics , ) *
92
+ @BOUNDS
93
+ // then specialised ones
94
+ $( $( $generics2 : $bounds $( + $morebounds ) * ) * ) *
95
+ > ) * {
96
+ $( $rest ) +
97
+ }
98
+ }
99
+ } ;
100
+
75
101
// entry-point. todo: make another for traits w/ bounds.
76
102
(
103
+ @WITH_BOUNDS
77
104
$( #[ $t_attr: meta] ) *
78
- pub trait $name: ident $( <$( $generics: ident) ,* >) * {
105
+ pub trait $name: ident $( <
106
+ $( $simple_generics: ident , ) *
107
+ @BOUNDS
108
+ $( $generics: ident $( : $bounds: tt $( + $morebounds: tt ) * ) * ) ,*
109
+ >) * {
79
110
$(
80
111
$( #[ doc=$m_doc: expr] ) *
81
112
#[ rpc( $( $t: tt) * ) ]
@@ -84,7 +115,7 @@ macro_rules! build_rpc_trait {
84
115
}
85
116
) => {
86
117
$( #[ $t_attr] ) *
87
- pub trait $name $( <$( $ generics, ) * >) * : Sized + Send + Sync + ' static {
118
+ pub trait $name $( <$( $simple_generics , ) * $ ( $ generics , ) * >) * : Sized + Send + Sync + ' static {
88
119
$(
89
120
$( #[ doc=$m_doc] ) *
90
121
fn $m_name ( $( $p) * ) -> $result<$out $( , $error) * > ;
@@ -93,7 +124,10 @@ macro_rules! build_rpc_trait {
93
124
/// Transform this into an `IoDelegate`, automatically wrapping
94
125
/// the parameters.
95
126
fn to_delegate<M : $crate:: jsonrpc_core:: Metadata >( self ) -> $crate:: IoDelegate <Self , M >
96
- where $( $( $generics: Send + Sync + ' static + $crate:: Serialize + $crate:: DeserializeOwned ) ,* ) *
127
+ where $(
128
+ $( $simple_generics: Send + Sync + ' static + $crate:: Serialize + $crate:: DeserializeOwned , ) *
129
+ $( $generics: Send + Sync + ' static $( + $bounds $( + $morebounds ) * ) * ) ,*
130
+ ) *
97
131
{
98
132
let mut del = $crate:: IoDelegate :: new( self . into( ) ) ;
99
133
$(
@@ -109,8 +143,13 @@ macro_rules! build_rpc_trait {
109
143
110
144
// entry-point for trait with metadata methods
111
145
(
146
+ @WITH_BOUNDS
112
147
$( #[ $t_attr: meta] ) *
113
- pub trait $name: ident $( <$( $generics: ident) ,* >) * {
148
+ pub trait $name: ident $( <
149
+ $( $simple_generics: ident , ) *
150
+ @BOUNDS
151
+ $( $generics: ident $( : $bounds: tt $( + $morebounds: tt ) * ) * ) ,*
152
+ >) * {
114
153
type Metadata ;
115
154
116
155
$(
@@ -133,7 +172,7 @@ macro_rules! build_rpc_trait {
133
172
}
134
173
) => {
135
174
$( #[ $t_attr] ) *
136
- pub trait $name $( <$( $ generics, ) * >) * : Sized + Send + Sync + ' static {
175
+ pub trait $name $( <$( $simple_generics , ) * $ ( $ generics , ) * >) * : Sized + Send + Sync + ' static {
137
176
// Metadata bound differs for traits with subscription methods.
138
177
metadata! (
139
178
$( $sub_name ) *
@@ -154,7 +193,10 @@ macro_rules! build_rpc_trait {
154
193
/// Transform this into an `IoDelegate`, automatically wrapping
155
194
/// the parameters.
156
195
fn to_delegate( self ) -> $crate:: IoDelegate <Self , Self :: Metadata >
157
- where $( $( $generics: Send + Sync + ' static + $crate:: Serialize + $crate:: DeserializeOwned ) ,* ) *
196
+ where $(
197
+ $( $simple_generics: Send + Sync + ' static + $crate:: Serialize + $crate:: DeserializeOwned ) ,*
198
+ $( $generics: Send + Sync + ' static $( + $bounds $( + $morebounds ) * ) * ) ,*
199
+ ) *
158
200
{
159
201
let mut del = $crate:: IoDelegate :: new( self . into( ) ) ;
160
202
$(
0 commit comments