33//! This module contains the definition of the raw client that wraps the transport method
44
55use std:: collections:: { BTreeMap , BTreeSet , HashMap , VecDeque } ;
6- use std:: convert:: TryFrom ;
76use std:: io:: { BufRead , BufReader , Read , Write } ;
87use std:: mem:: drop;
98use std:: net:: { TcpStream , ToSocketAddrs } ;
@@ -348,6 +347,8 @@ impl RawClient<ElectrumSslStream> {
348347 validate_domain : bool ,
349348 tcp_stream : TcpStream ,
350349 ) -> Result < Self , Error > {
350+ use std:: convert:: TryFrom ;
351+
351352 let builder = ClientConfig :: builder ( ) . with_safe_defaults ( ) ;
352353
353354 let config = if validate_domain {
@@ -658,6 +659,21 @@ impl<S: Read + Write> RawClient<S> {
658659 Ok ( ( ) )
659660 }
660661
662+ pub ( crate ) fn internal_raw_call_with_vec (
663+ & self ,
664+ method_name : & str ,
665+ params : Vec < Param > ,
666+ ) -> Result < serde_json:: Value , Error > {
667+ let req = Request :: new_id (
668+ self . last_id . fetch_add ( 1 , Ordering :: SeqCst ) ,
669+ & method_name,
670+ params,
671+ ) ;
672+ let result = self . call ( req) ?;
673+
674+ Ok ( result)
675+ }
676+
661677 #[ inline]
662678 #[ cfg( feature = "debug-calls" ) ]
663679 fn increment_calls ( & self ) {
@@ -670,15 +686,12 @@ impl<S: Read + Write> RawClient<S> {
670686}
671687
672688impl < T : Read + Write > ElectrumApi for RawClient < T > {
673- fn raw_call ( & self , call : & Call ) -> Result < serde_json:: Value , Error > {
674- let req = Request :: new_id (
675- self . last_id . fetch_add ( 1 , Ordering :: SeqCst ) ,
676- & call. 0 ,
677- call. 1 . to_vec ( ) ,
678- ) ;
679- let result = self . call ( req) ?;
680-
681- Ok ( result)
689+ fn raw_call (
690+ & self ,
691+ method_name : & str ,
692+ params : impl IntoIterator < Item = Param > ,
693+ ) -> Result < serde_json:: Value , Error > {
694+ self . internal_raw_call_with_vec ( method_name, params. into_iter ( ) . collect ( ) )
682695 }
683696
684697 fn batch_call ( & self , batch : & Batch ) -> Result < Vec < serde_json:: Value > , Error > {
@@ -1312,9 +1325,10 @@ mod test {
13121325 ) ,
13131326 Param :: Bool ( false ) ,
13141327 ] ;
1315- let call = ( "blockchain.transaction.get" . to_string ( ) , params) ;
13161328
1317- let resp = client. raw_call ( & call) . unwrap ( ) ;
1329+ let resp = client
1330+ . raw_call ( "blockchain.transaction.get" , params)
1331+ . unwrap ( ) ;
13181332
13191333 assert_eq ! (
13201334 resp,
0 commit comments