Skip to content

Commit 68ecc31

Browse files
committed
chore(docs): minor improvements on docstrings
- apply some standard on `Cargo.toml` deps. - minor docstring improvements, and fix missing docstrings.
1 parent bcb66e6 commit 68ecc31

File tree

5 files changed

+18
-16
lines changed

5 files changed

+18
-16
lines changed

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ path = "src/lib.rs"
1919
[dependencies]
2020
serde = { version = "1.0", features = ["derive"] }
2121
bitcoin = { version = "0.32", features = ["serde", "std"], default-features = false }
22-
hex = { package = "hex-conservative", version = "0.2" }
22+
hex = { version = "0.2", package = "hex-conservative" }
2323
log = "^0.4"
2424
minreq = { version = "2.11.0", features = ["json-using-serde"], optional = true }
25-
reqwest = { version = "0.11", optional = true, default-features = false, features = ["json"] }
25+
reqwest = { version = "0.11", features = ["json"], default-features = false, optional = true }
2626

2727
[dev-dependencies]
2828
serde_json = "1.0"

src/api.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
//! structs from the esplora API
1+
//! Structs from the Esplora API
22
//!
3-
//! see: <https://github.com/Blockstream/esplora/blob/master/API.md>
3+
//! See: <https://github.com/Blockstream/esplora/blob/master/API.md>
44
55
pub use bitcoin::consensus::{deserialize, serialize};
66
pub use bitcoin::hex::FromHex;

src/async.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,14 @@ use crate::{BlockStatus, BlockSummary, Builder, Error, MerkleProof, OutputStatus
3030

3131
#[derive(Debug, Clone)]
3232
pub struct AsyncClient {
33+
/// The URL of the Esplora Server.
3334
url: String,
35+
/// The inner [`reqwest::Client`] to make HTTP requests.
3436
client: Client,
3537
}
3638

3739
impl AsyncClient {
38-
/// build an async client from a builder
40+
/// Build an async client from a builder
3941
pub fn from_builder(builder: Builder) -> Result<Self, Error> {
4042
let mut client_builder = Client::builder();
4143

@@ -64,7 +66,7 @@ impl AsyncClient {
6466
Ok(Self::from_client(builder.base_url, client_builder.build()?))
6567
}
6668

67-
/// build an async client from the base url and [`Client`]
69+
/// Build an async client from the base url and [`Client`]
6870
pub fn from_client(url: String, client: Client) -> Self {
6971
AsyncClient { url, client }
7072
}

src/blocking.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ use crate::{BlockStatus, BlockSummary, Builder, Error, MerkleProof, OutputStatus
3131

3232
#[derive(Debug, Clone)]
3333
pub struct BlockingClient {
34+
/// The URL of the Esplora server.
3435
url: String,
3536
/// The proxy is ignored when targeting `wasm32`.
3637
pub proxy: Option<String>,
@@ -41,7 +42,7 @@ pub struct BlockingClient {
4142
}
4243

4344
impl BlockingClient {
44-
/// build a blocking client from a [`Builder`]
45+
/// Build a blocking client from a [`Builder`]
4546
pub fn from_builder(builder: Builder) -> Self {
4647
Self {
4748
url: builder.base_url,

src/lib.rs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,6 @@ use std::collections::HashMap;
7272
use std::fmt;
7373
use std::num::TryFromIntError;
7474

75-
use bitcoin::consensus;
76-
7775
pub mod api;
7876

7977
#[cfg(feature = "async")]
@@ -102,6 +100,7 @@ pub fn convert_fee_rate(target: usize, estimates: HashMap<u16, f64>) -> Option<f
102100

103101
#[derive(Debug, Clone)]
104102
pub struct Builder {
103+
/// The URL of the Esplora server.
105104
pub base_url: String,
106105
/// Optional URL of the proxy to use to make requests to the Esplora server
107106
///
@@ -118,7 +117,7 @@ pub struct Builder {
118117
pub proxy: Option<String>,
119118
/// Socket timeout.
120119
pub timeout: Option<u64>,
121-
/// HTTP headers to set on every request made to Esplora server
120+
/// HTTP headers to set on every request made to Esplora server.
122121
pub headers: HashMap<String, String>,
123122
}
124123

@@ -151,20 +150,20 @@ impl Builder {
151150
self
152151
}
153152

154-
/// build a blocking client from builder
153+
/// Build a blocking client from builder
155154
#[cfg(feature = "blocking")]
156155
pub fn build_blocking(self) -> BlockingClient {
157156
BlockingClient::from_builder(self)
158157
}
159158

160-
// build an asynchronous client from builder
159+
// Build an asynchronous client from builder
161160
#[cfg(feature = "async")]
162161
pub fn build_async(self) -> Result<AsyncClient, Error> {
163162
AsyncClient::from_builder(self)
164163
}
165164
}
166165

167-
/// Errors that can happen during a sync with `Esplora`
166+
/// Errors that can happen during a request to `Esplora` servers.
168167
#[derive(Debug)]
169168
pub enum Error {
170169
/// Error during `minreq` HTTP request
@@ -187,9 +186,9 @@ pub enum Error {
187186
HexToBytes(bitcoin::hex::HexToBytesError),
188187
/// Transaction not found
189188
TransactionNotFound(Txid),
190-
/// Header height not found
189+
/// Block Header height not found
191190
HeaderHeightNotFound(u32),
192-
/// Header hash not found
191+
/// Block Header hash not found
193192
HeaderHashNotFound(BlockHash),
194193
/// Invalid HTTP Header name specified
195194
InvalidHttpHeaderName(String),
@@ -222,7 +221,7 @@ impl_error!(::minreq::Error, Minreq, Error);
222221
#[cfg(feature = "async")]
223222
impl_error!(::reqwest::Error, Reqwest, Error);
224223
impl_error!(std::num::ParseIntError, Parsing, Error);
225-
impl_error!(consensus::encode::Error, BitcoinEncoding, Error);
224+
impl_error!(bitcoin::consensus::encode::Error, BitcoinEncoding, Error);
226225
impl_error!(bitcoin::hex::HexToArrayError, HexToArray, Error);
227226
impl_error!(bitcoin::hex::HexToBytesError, HexToBytes, Error);
228227

0 commit comments

Comments
 (0)