From 1103936477a2f502658b6240ea9be8917e8f12b0 Mon Sep 17 00:00:00 2001 From: Leonardo Lima Date: Mon, 9 Sep 2024 15:01:31 -0300 Subject: [PATCH] chore(style+docs): style and docs retouch --- src/async.rs | 28 ++++++++-------------------- 1 file changed, 8 insertions(+), 20 deletions(-) diff --git a/src/async.rs b/src/async.rs index 8a56f2a..ac0a761 100644 --- a/src/async.rs +++ b/src/async.rs @@ -104,10 +104,7 @@ impl AsyncClient { async fn get_opt_response(&self, path: &str) -> Result, Error> { match self.get_response::(path).await { Ok(res) => Ok(Some(res)), - Err(Error::HttpResponse { status, message }) => match status { - 404 => Ok(None), - _ => Err(Error::HttpResponse { status, message }), - }, + Err(Error::HttpResponse { status: 404, .. }) => Ok(None), Err(e) => Err(e), } } @@ -151,20 +148,17 @@ impl AsyncClient { ) -> Result, Error> { match self.get_response_json(url).await { Ok(res) => Ok(Some(res)), - Err(Error::HttpResponse { status, message }) => match status { - 404 => Ok(None), - _ => Err(Error::HttpResponse { status, message }), - }, + Err(Error::HttpResponse { status: 404, .. }) => Ok(None), Err(e) => Err(e), } } /// Make an HTTP GET request to given URL, deserializing to any `T` that - /// implement [`bitcoin::consensus::Decodable`] from Hex, [`Vec`]. + /// implements [`bitcoin::consensus::Decodable`]. /// - /// It should be used when requesting Esplora endpoints that can be directly - /// deserialized to native `rust-bitcoin` types, which implements - /// [`bitcoin::consensus::Decodable`] from Hex, `Vec<&u8>`. + /// It should be used when requesting Esplora endpoints that are expected + /// to return a hex string decodable to native `rust-bitcoin` types which + /// implement [`bitcoin::consensus::Decodable`] from `&[u8]`. /// /// # Errors /// @@ -194,10 +188,7 @@ impl AsyncClient { async fn get_opt_response_hex(&self, path: &str) -> Result, Error> { match self.get_response_hex(path).await { Ok(res) => Ok(Some(res)), - Err(Error::HttpResponse { status, message }) => match status { - 404 => Ok(None), - _ => Err(Error::HttpResponse { status, message }), - }, + Err(Error::HttpResponse { status: 404, .. }) => Ok(None), Err(e) => Err(e), } } @@ -233,10 +224,7 @@ impl AsyncClient { async fn get_opt_response_text(&self, path: &str) -> Result, Error> { match self.get_response_text(path).await { Ok(s) => Ok(Some(s)), - Err(Error::HttpResponse { status, message }) => match status { - 404 => Ok(None), - _ => Err(Error::HttpResponse { status, message }), - }, + Err(Error::HttpResponse { status: 404, .. }) => Ok(None), Err(e) => Err(e), } }