6666
6767#![ allow( clippy:: result_large_err) ]
6868
69- use std:: collections:: HashMap ;
7069use std:: fmt;
7170use std:: num:: TryFromIntError ;
7271use std:: time:: Duration ;
72+ use std:: { collections:: HashMap , marker:: PhantomData } ;
7373
7474pub mod api;
7575
@@ -137,7 +137,7 @@ pub struct Builder<R = DefaultRuntime> {
137137 /// Max retries
138138 pub max_retries : usize ,
139139 /// Async runtime, trait must implement `sleep` function, default is `tokio`
140- pub runtime : R ,
140+ pub runtime : PhantomData < R > ,
141141}
142142
143143impl Builder {
@@ -149,7 +149,7 @@ impl Builder {
149149 timeout : None ,
150150 headers : HashMap :: new ( ) ,
151151 max_retries : DEFAULT_MAX_RETRIES ,
152- runtime : DefaultRuntime ,
152+ runtime : PhantomData ,
153153 }
154154 }
155155
@@ -164,16 +164,16 @@ impl<R: Runtime> Builder<R>
164164where
165165 R : Runtime ,
166166{
167- /// New with runtime
167+ /// Instantiate a new builder, with a custom runtime
168168 #[ cfg( feature = "async" ) ]
169- pub fn new_with_runtime ( base_url : & str , runtime : R ) -> Self {
169+ pub fn new_custom_runtime ( base_url : & str ) -> Self {
170170 Builder {
171171 base_url : base_url. to_string ( ) ,
172172 proxy : None ,
173173 timeout : None ,
174174 headers : HashMap :: new ( ) ,
175175 max_retries : DEFAULT_MAX_RETRIES ,
176- runtime,
176+ runtime : PhantomData ,
177177 }
178178 }
179179
@@ -1046,10 +1046,8 @@ mod test {
10461046 #[ cfg( not( feature = "tokio" ) ) ]
10471047 #[ test]
10481048 fn use_with_custom_runtime ( ) {
1049- let builder = Builder :: < TestRuntime > :: new_with_runtime (
1050- "https://blockstream.info/testnet/api" ,
1051- TestRuntime ,
1052- ) ;
1049+ let builder =
1050+ Builder :: < TestRuntime > :: new_with_runtime ( "https://blockstream.info/testnet/api" ) ;
10531051
10541052 let client = builder. build_async ( ) ;
10551053 assert ! ( client. is_ok( ) ) ;
0 commit comments