@@ -27,7 +27,7 @@ impl std::fmt::Debug for AwClient {
27
27
28
28
impl AwClient {
29
29
pub fn new ( ip : & str , port : & str , name : & str ) -> AwClient {
30
- let baseurl = format ! ( "http://{}:{}" , ip , port ) ;
30
+ let baseurl = format ! ( "http://{ip }:{port}" ) ;
31
31
let client = reqwest:: blocking:: Client :: builder ( )
32
32
. timeout ( std:: time:: Duration :: from_secs ( 120 ) )
33
33
. build ( )
@@ -43,18 +43,18 @@ impl AwClient {
43
43
44
44
pub fn get_bucket ( & self , bucketname : & str ) -> Result < Bucket , reqwest:: Error > {
45
45
let url = format ! ( "{}/api/0/buckets/{}" , self . baseurl, bucketname) ;
46
- let bucket = self . client . get ( & url) . send ( ) ?. error_for_status ( ) ?. json ( ) ?;
46
+ let bucket = self . client . get ( url) . send ( ) ?. error_for_status ( ) ?. json ( ) ?;
47
47
Ok ( bucket)
48
48
}
49
49
50
50
pub fn get_buckets ( & self ) -> Result < HashMap < String , Bucket > , reqwest:: Error > {
51
51
let url = format ! ( "{}/api/0/buckets/" , self . baseurl) ;
52
- self . client . get ( & url) . send ( ) ?. json ( )
52
+ self . client . get ( url) . send ( ) ?. json ( )
53
53
}
54
54
55
55
pub fn create_bucket ( & self , bucket : & Bucket ) -> Result < ( ) , reqwest:: Error > {
56
56
let url = format ! ( "{}/api/0/buckets/{}" , self . baseurl, bucket. id) ;
57
- self . client . post ( & url) . json ( bucket) . send ( ) ?;
57
+ self . client . post ( url) . json ( bucket) . send ( ) ?;
58
58
Ok ( ( ) )
59
59
}
60
60
@@ -80,7 +80,7 @@ impl AwClient {
80
80
81
81
pub fn delete_bucket ( & self , bucketname : & str ) -> Result < ( ) , reqwest:: Error > {
82
82
let url = format ! ( "{}/api/0/buckets/{}" , self . baseurl, bucketname) ;
83
- self . client . delete ( & url) . send ( ) ?;
83
+ self . client . delete ( url) . send ( ) ?;
84
84
Ok ( ( ) )
85
85
}
86
86
@@ -115,7 +115,7 @@ impl AwClient {
115
115
pub fn insert_event ( & self , bucketname : & str , event : & Event ) -> Result < ( ) , reqwest:: Error > {
116
116
let url = format ! ( "{}/api/0/buckets/{}/events" , self . baseurl, bucketname) ;
117
117
let eventlist = vec ! [ event. clone( ) ] ;
118
- self . client . post ( & url) . json ( & eventlist) . send ( ) ?;
118
+ self . client . post ( url) . json ( & eventlist) . send ( ) ?;
119
119
Ok ( ( ) )
120
120
}
121
121
@@ -125,7 +125,7 @@ impl AwClient {
125
125
events : Vec < Event > ,
126
126
) -> Result < ( ) , reqwest:: Error > {
127
127
let url = format ! ( "{}/api/0/buckets/{}/events" , self . baseurl, bucketname) ;
128
- self . client . post ( & url) . json ( & events) . send ( ) ?;
128
+ self . client . post ( url) . json ( & events) . send ( ) ?;
129
129
Ok ( ( ) )
130
130
}
131
131
@@ -139,7 +139,7 @@ impl AwClient {
139
139
"{}/api/0/buckets/{}/heartbeat?pulsetime={}" ,
140
140
self . baseurl, bucketname, pulsetime
141
141
) ;
142
- self . client . post ( & url) . json ( & event) . send ( ) ?;
142
+ self . client . post ( url) . json ( & event) . send ( ) ?;
143
143
Ok ( ( ) )
144
144
}
145
145
@@ -148,22 +148,22 @@ impl AwClient {
148
148
"{}/api/0/buckets/{}/events/{}" ,
149
149
self . baseurl, bucketname, event_id
150
150
) ;
151
- self . client . delete ( & url) . send ( ) ?;
151
+ self . client . delete ( url) . send ( ) ?;
152
152
Ok ( ( ) )
153
153
}
154
154
155
155
pub fn get_event_count ( & self , bucketname : & str ) -> Result < i64 , reqwest:: Error > {
156
156
let url = format ! ( "{}/api/0/buckets/{}/events/count" , self . baseurl, bucketname) ;
157
- let res = self . client . get ( & url) . send ( ) ?. error_for_status ( ) ?. text ( ) ?;
157
+ let res = self . client . get ( url) . send ( ) ?. error_for_status ( ) ?. text ( ) ?;
158
158
let count: i64 = match res. trim ( ) . parse ( ) {
159
159
Ok ( count) => count,
160
- Err ( err) => panic ! ( "could not parse get_event_count response: {:?}" , err ) ,
160
+ Err ( err) => panic ! ( "could not parse get_event_count response: {err :?}" ) ,
161
161
} ;
162
162
Ok ( count)
163
163
}
164
164
165
165
pub fn get_info ( & self ) -> Result < aw_models:: Info , reqwest:: Error > {
166
166
let url = format ! ( "{}/api/0/info" , self . baseurl) ;
167
- self . client . get ( & url) . send ( ) ?. json ( )
167
+ self . client . get ( url) . send ( ) ?. json ( )
168
168
}
169
169
}
0 commit comments