66
66
67
67
#![ allow( clippy:: result_large_err) ]
68
68
69
- use std:: collections:: HashMap ;
70
69
use std:: fmt;
71
70
use std:: num:: TryFromIntError ;
72
71
use std:: time:: Duration ;
72
+ use std:: { collections:: HashMap , marker:: PhantomData } ;
73
73
74
74
pub mod api;
75
75
@@ -137,7 +137,7 @@ pub struct Builder<R = DefaultRuntime> {
137
137
/// Max retries
138
138
pub max_retries : usize ,
139
139
/// Async runtime, trait must implement `sleep` function, default is `tokio`
140
- pub runtime : R ,
140
+ pub runtime : PhantomData < R > ,
141
141
}
142
142
143
143
impl Builder {
@@ -149,7 +149,7 @@ impl Builder {
149
149
timeout : None ,
150
150
headers : HashMap :: new ( ) ,
151
151
max_retries : DEFAULT_MAX_RETRIES ,
152
- runtime : DefaultRuntime ,
152
+ runtime : PhantomData ,
153
153
}
154
154
}
155
155
@@ -164,16 +164,16 @@ impl<R: Runtime> Builder<R>
164
164
where
165
165
R : Runtime ,
166
166
{
167
- /// New with runtime
167
+ /// Instantiate a new builder, with a custom runtime
168
168
#[ 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 {
170
170
Builder {
171
171
base_url : base_url. to_string ( ) ,
172
172
proxy : None ,
173
173
timeout : None ,
174
174
headers : HashMap :: new ( ) ,
175
175
max_retries : DEFAULT_MAX_RETRIES ,
176
- runtime,
176
+ runtime : PhantomData ,
177
177
}
178
178
}
179
179
@@ -1046,10 +1046,8 @@ mod test {
1046
1046
#[ cfg( not( feature = "tokio" ) ) ]
1047
1047
#[ test]
1048
1048
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" ) ;
1053
1051
1054
1052
let client = builder. build_async ( ) ;
1055
1053
assert ! ( client. is_ok( ) ) ;
0 commit comments