6
6
//! the AWS Lambda Runtime API.
7
7
use http:: { uri:: PathAndQuery , uri:: Scheme , Request , Response , Uri } ;
8
8
use hyper:: body:: Incoming ;
9
- use hyper_util:: client:: legacy:: connect:: { Connect , Connection , HttpConnector } ;
9
+ use hyper_util:: client:: legacy:: connect:: HttpConnector ;
10
10
use std:: { convert:: TryInto , fmt:: Debug } ;
11
- use tower_service:: Service ;
12
11
13
12
const USER_AGENT_HEADER : & str = "User-Agent" ;
14
13
const DEFAULT_USER_AGENT : & str = concat ! ( "aws-lambda-rust/" , env!( "CARGO_PKG_VERSION" ) ) ;
@@ -20,27 +19,24 @@ pub mod body;
20
19
21
20
/// API client to interact with the AWS Lambda Runtime API.
22
21
#[ derive( Debug ) ]
23
- pub struct Client < C = HttpConnector > {
22
+ pub struct Client {
24
23
/// The runtime API URI
25
24
pub base : Uri ,
26
25
/// The client that manages the API connections
27
- pub client : hyper_util:: client:: legacy:: Client < C , body:: Body > ,
26
+ pub client : hyper_util:: client:: legacy:: Client < HttpConnector , body:: Body > ,
28
27
}
29
28
30
29
impl Client {
31
30
/// Create a builder struct to configure the client.
32
- pub fn builder ( ) -> ClientBuilder < HttpConnector > {
31
+ pub fn builder ( ) -> ClientBuilder {
33
32
ClientBuilder {
34
33
connector : HttpConnector :: new ( ) ,
35
34
uri : None ,
36
35
}
37
36
}
38
37
}
39
38
40
- impl < C > Client < C >
41
- where
42
- C : Connect + Sync + Send + Clone + ' static ,
43
- {
39
+ impl Client {
44
40
/// Send a given request to the Runtime API.
45
41
/// Use the client's base URI to ensure the API endpoint is correct.
46
42
pub async fn call ( & self , req : Request < body:: Body > ) -> Result < Response < Incoming > , BoxError > {
49
45
}
50
46
51
47
/// Create a new client with a given base URI and HTTP connector.
52
- pub fn with ( base : Uri , connector : C ) -> Self {
48
+ fn with ( base : Uri , connector : HttpConnector ) -> Self {
53
49
let client = hyper_util:: client:: legacy:: Client :: builder ( hyper_util:: rt:: TokioExecutor :: new ( ) )
54
50
. http1_max_buf_size ( 1024 * 1024 )
55
51
. build ( connector) ;
@@ -80,26 +76,14 @@ where
80
76
}
81
77
82
78
/// Builder implementation to construct any Runtime API clients.
83
- pub struct ClientBuilder < C : Service < http :: Uri > = HttpConnector > {
84
- connector : C ,
79
+ pub struct ClientBuilder {
80
+ connector : HttpConnector ,
85
81
uri : Option < http:: Uri > ,
86
82
}
87
83
88
- impl < C > ClientBuilder < C >
89
- where
90
- C : Service < http:: Uri > + Clone + Send + Sync + Unpin + ' static ,
91
- <C as Service < http:: Uri > >:: Future : Unpin + Send ,
92
- <C as Service < http:: Uri > >:: Error : Into < Box < dyn std:: error:: Error + Send + Sync > > ,
93
- <C as Service < http:: Uri > >:: Response : Connection + Unpin + Send + ' static ,
94
- {
84
+ impl ClientBuilder {
95
85
/// Create a new builder with a given HTTP connector.
96
- pub fn with_connector < C2 > ( self , connector : C2 ) -> ClientBuilder < C2 >
97
- where
98
- C2 : Service < http:: Uri > + Clone + Send + Sync + Unpin + ' static ,
99
- <C2 as Service < http:: Uri > >:: Future : Unpin + Send ,
100
- <C2 as Service < http:: Uri > >:: Error : Into < Box < dyn std:: error:: Error + Send + Sync > > ,
101
- <C2 as Service < http:: Uri > >:: Response : Connection + Unpin + Send + ' static ,
102
- {
86
+ pub fn with_connector ( self , connector : HttpConnector ) -> ClientBuilder {
103
87
ClientBuilder {
104
88
connector,
105
89
uri : self . uri ,
@@ -113,10 +97,7 @@ where
113
97
}
114
98
115
99
/// Create the new client to interact with the Runtime API.
116
- pub fn build ( self ) -> Result < Client < C > , Error >
117
- where
118
- C : Connect + Sync + Send + Clone + ' static ,
119
- {
100
+ pub fn build ( self ) -> Result < Client , Error > {
120
101
let uri = match self . uri {
121
102
Some ( uri) => uri,
122
103
None => {
0 commit comments