File tree Expand file tree Collapse file tree 2 files changed +52
-2
lines changed Expand file tree Collapse file tree 2 files changed +52
-2
lines changed Original file line number Diff line number Diff line change @@ -52,6 +52,9 @@ use hyper_tls::HttpsConnector;
52
52
#[ cfg( feature = "rustls" ) ]
53
53
use hyper_rustls:: { HttpsConnector , HttpsConnectorBuilder } ;
54
54
55
+ use resolvers:: GaiResolver ;
56
+
57
+ pub mod resolvers;
55
58
#[ cfg( feature = "blocking" ) ]
56
59
pub mod blocking;
57
60
@@ -121,7 +124,7 @@ impl<T> Deref for Response<T> {
121
124
}
122
125
123
126
/// REST client to make HTTP GET and POST requests.
124
- pub struct RestClient < R = dns :: GaiResolver > {
127
+ pub struct RestClient < R = GaiResolver > {
125
128
client : HyperClient < R > ,
126
129
baseurl : url:: Url ,
127
130
auth : Option < String > ,
@@ -170,7 +173,7 @@ pub enum Error {
170
173
}
171
174
172
175
/// Builder for `RestClient`
173
- pub struct Builder < R = dns :: GaiResolver > {
176
+ pub struct Builder < R = GaiResolver > {
174
177
/// Request timeout
175
178
timeout : Duration ,
176
179
Original file line number Diff line number Diff line change
1
+ use core:: task:: { Context , Poll } ;
2
+
3
+ use hyper:: client:: connect:: dns:: { self , GaiResolver as HyperGaiResolver } ;
4
+ use hyper:: service:: Service ;
5
+
6
+ /// Newtype wrapper around hyper's GaiResolver to provide Default
7
+ /// trait implementation
8
+ #[ derive( Clone , Debug ) ]
9
+ pub struct GaiResolver ( HyperGaiResolver ) ;
10
+
11
+ impl GaiResolver {
12
+ pub fn new ( ) -> Self {
13
+ Self :: default ( )
14
+ }
15
+ }
16
+
17
+ impl From < HyperGaiResolver > for GaiResolver {
18
+ fn from ( gai : HyperGaiResolver ) -> Self {
19
+ Self ( gai)
20
+ }
21
+ }
22
+
23
+ impl Into < HyperGaiResolver > for GaiResolver {
24
+ fn into ( self ) -> HyperGaiResolver {
25
+ self . 0
26
+ }
27
+ }
28
+
29
+ impl Default for GaiResolver {
30
+ fn default ( ) -> Self {
31
+ Self ( HyperGaiResolver :: new ( ) )
32
+ }
33
+ }
34
+
35
+ impl Service < dns:: Name > for GaiResolver {
36
+ type Response = <HyperGaiResolver as Service < dns:: Name > >:: Response ;
37
+ type Error = <HyperGaiResolver as Service < dns:: Name > >:: Error ;
38
+ type Future = <HyperGaiResolver as Service < dns:: Name > >:: Future ;
39
+
40
+ fn poll_ready ( & mut self , cx : & mut Context < ' _ > ) -> Poll < Result < ( ) , Self :: Error > > {
41
+ self . 0 . poll_ready ( cx)
42
+ }
43
+
44
+ fn call ( & mut self , name : dns:: Name ) -> Self :: Future {
45
+ self . 0 . call ( name)
46
+ }
47
+ }
You can’t perform that action at this time.
0 commit comments