@@ -104,10 +104,7 @@ impl AsyncClient {
104104 async fn get_opt_response < T : Decodable > ( & self , path : & str ) -> Result < Option < T > , Error > {
105105 match self . get_response :: < T > ( path) . await {
106106 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 ) ,
111108 Err ( e) => Err ( e) ,
112109 }
113110 }
@@ -151,20 +148,17 @@ impl AsyncClient {
151148 ) -> Result < Option < T > , Error > {
152149 match self . get_response_json ( url) . await {
153150 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 ) ,
158152 Err ( e) => Err ( e) ,
159153 }
160154 }
161155
162156 /// 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`].
164158 ///
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] `.
168162 ///
169163 /// # Errors
170164 ///
@@ -194,10 +188,7 @@ impl AsyncClient {
194188 async fn get_opt_response_hex < T : Decodable > ( & self , path : & str ) -> Result < Option < T > , Error > {
195189 match self . get_response_hex ( path) . await {
196190 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 ) ,
201192 Err ( e) => Err ( e) ,
202193 }
203194 }
@@ -233,10 +224,7 @@ impl AsyncClient {
233224 async fn get_opt_response_text ( & self , path : & str ) -> Result < Option < String > , Error > {
234225 match self . get_response_text ( path) . await {
235226 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 ) ,
240228 Err ( e) => Err ( e) ,
241229 }
242230 }
0 commit comments