@@ -126,7 +126,7 @@ impl<T> Future for RpcRequest<T> {
126
126
127
127
/// Trait for types acting as a transport layer for the JSON-RPC 2.0 clients generated by the
128
128
/// `jsonrpc_client` macro.
129
- pub trait Transport : Clone + Send + ' static {
129
+ pub trait Transport {
130
130
/// The type of error that this transport emits if it fails.
131
131
type Error : :: std:: error:: Error + Send + ' static ;
132
132
@@ -147,7 +147,7 @@ pub trait Transport: Clone + Send + 'static {
147
147
/// # Not intended for direct use
148
148
/// This is being called from the client structs generated by the `jsonrpc_client` macro. This
149
149
/// function is not intended to be used directly, only the generated structs should call this.
150
- pub fn call_method < T , P , R > ( mut transport : T , method : String , params : P ) -> RpcRequest < R >
150
+ pub fn call_method < T , P , R > ( transport : & mut T , method : String , params : P ) -> RpcRequest < R >
151
151
where
152
152
T : Transport ,
153
153
P : serde:: Serialize ,
@@ -160,31 +160,30 @@ where
160
160
method,
161
161
raw_id
162
162
) ;
163
- let request = serialize_request ( id. clone ( ) , method. clone ( ) , params)
163
+ let request_serialization_result = serialize_request ( id. clone ( ) , method. clone ( ) , params)
164
164
. chain_err ( || ErrorKind :: SerializeError ) ;
165
- let method_copy1 = method. clone ( ) ;
166
- let method_copy2 = method. clone ( ) ;
167
-
168
- let future = futures:: future:: result ( request)
169
- . and_then ( move |request_raw| {
165
+ match request_serialization_result {
166
+ Err ( e) => RpcRequest ( Box :: new ( futures:: future:: err ( e) ) ) ,
167
+ Ok ( request_raw) => {
170
168
trace ! (
171
169
"Sending call to method \" {}\" with id {} to transport" ,
172
- method_copy1 ,
170
+ method ,
173
171
raw_id
174
172
) ;
175
- transport
173
+ let future = transport
176
174
. send ( request_raw)
177
175
. map_err ( |e| Error :: with_chain ( e, ErrorKind :: TransportError ) )
178
- } )
179
- . and_then ( move |response_raw : Vec < u8 > | {
180
- trace ! (
181
- "Deserializing response to method \" {}\" with id {}" ,
182
- method_copy2,
183
- raw_id
184
- ) ;
185
- response:: parse :: < R > ( & response_raw, id)
186
- } ) ;
187
- RpcRequest ( Box :: new ( future) )
176
+ . and_then ( move |response_raw : Vec < u8 > | {
177
+ trace ! (
178
+ "Deserializing response to method \" {}\" with id {}" ,
179
+ method,
180
+ raw_id
181
+ ) ;
182
+ response:: parse :: < R > ( & response_raw, id)
183
+ } ) ;
184
+ RpcRequest ( Box :: new ( future) )
185
+ }
186
+ }
188
187
}
189
188
190
189
@@ -205,7 +204,7 @@ where
205
204
} ;
206
205
let method_call = MethodCall {
207
206
jsonrpc : Some ( Version :: V2 ) ,
208
- method : method . to_owned ( ) ,
207
+ method,
209
208
params : serialized_params,
210
209
id,
211
210
} ;
0 commit comments