@@ -104,10 +104,7 @@ impl AsyncClient {
104
104
async fn get_opt_response < T : Decodable > ( & self , path : & str ) -> Result < Option < T > , Error > {
105
105
match self . get_response :: < T > ( path) . await {
106
106
Ok ( res) => Ok ( Some ( res) ) ,
107
- Err ( Error :: HttpResponse { status, message } ) => match status {
108
- 404 => Ok ( None ) ,
109
- _ => Err ( Error :: HttpResponse { status, message } ) ,
110
- } ,
107
+ Err ( Error :: HttpResponse { status : 404 , .. } ) => Ok ( None ) ,
111
108
Err ( e) => Err ( e) ,
112
109
}
113
110
}
@@ -151,20 +148,17 @@ impl AsyncClient {
151
148
) -> Result < Option < T > , Error > {
152
149
match self . get_response_json ( url) . await {
153
150
Ok ( res) => Ok ( Some ( res) ) ,
154
- Err ( Error :: HttpResponse { status, message } ) => match status {
155
- 404 => Ok ( None ) ,
156
- _ => Err ( Error :: HttpResponse { status, message } ) ,
157
- } ,
151
+ Err ( Error :: HttpResponse { status : 404 , .. } ) => Ok ( None ) ,
158
152
Err ( e) => Err ( e) ,
159
153
}
160
154
}
161
155
162
156
/// Make an HTTP GET request to given URL, deserializing to any `T` that
163
- /// implement [`bitcoin::consensus::Decodable`] from Hex, [`Vec<u8> `].
157
+ /// implements [`bitcoin::consensus::Decodable`].
164
158
///
165
- /// It should be used when requesting Esplora endpoints that can be directly
166
- /// deserialized to native `rust-bitcoin` types, which implements
167
- /// [`bitcoin::consensus::Decodable`] from Hex, `Vec<&u8> `.
159
+ /// It should be used when requesting Esplora endpoints that are expected
160
+ /// to return a hex string decodable to native `rust-bitcoin` types which
161
+ /// implement [`bitcoin::consensus::Decodable`] from `&[u8] `.
168
162
///
169
163
/// # Errors
170
164
///
@@ -194,10 +188,7 @@ impl AsyncClient {
194
188
async fn get_opt_response_hex < T : Decodable > ( & self , path : & str ) -> Result < Option < T > , Error > {
195
189
match self . get_response_hex ( path) . await {
196
190
Ok ( res) => Ok ( Some ( res) ) ,
197
- Err ( Error :: HttpResponse { status, message } ) => match status {
198
- 404 => Ok ( None ) ,
199
- _ => Err ( Error :: HttpResponse { status, message } ) ,
200
- } ,
191
+ Err ( Error :: HttpResponse { status : 404 , .. } ) => Ok ( None ) ,
201
192
Err ( e) => Err ( e) ,
202
193
}
203
194
}
@@ -233,10 +224,7 @@ impl AsyncClient {
233
224
async fn get_opt_response_text ( & self , path : & str ) -> Result < Option < String > , Error > {
234
225
match self . get_response_text ( path) . await {
235
226
Ok ( s) => Ok ( Some ( s) ) ,
236
- Err ( Error :: HttpResponse { status, message } ) => match status {
237
- 404 => Ok ( None ) ,
238
- _ => Err ( Error :: HttpResponse { status, message } ) ,
239
- } ,
227
+ Err ( Error :: HttpResponse { status : 404 , .. } ) => Ok ( None ) ,
240
228
Err ( e) => Err ( e) ,
241
229
}
242
230
}
0 commit comments