Skip to content

Commit 32a7012

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 1a4d5cf commit 32a7012

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
@@ -70,8 +70,6 @@ use std::collections::HashMap;
7070
use std::fmt;
7171
use std::num::TryFromIntError;
7272

73-
use bitcoin::consensus;
74-
7573
pub mod api;
7674

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

10199
#[derive(Debug, Clone)]
102100
pub struct Builder {
101+
/// The URL of the Esplora server.
103102
pub base_url: String,
104103
/// Optional URL of the proxy to use to make requests to the Esplora server
105104
///
@@ -116,7 +115,7 @@ pub struct Builder {
116115
pub proxy: Option<String>,
117116
/// Socket timeout.
118117
pub timeout: Option<u64>,
119-
/// HTTP headers to set on every request made to Esplora server
118+
/// HTTP headers to set on every request made to Esplora server.
120119
pub headers: HashMap<String, String>,
121120
}
122121

@@ -149,20 +148,20 @@ impl Builder {
149148
self
150149
}
151150

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

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

165-
/// Errors that can happen during a sync with `Esplora`
164+
/// Errors that can happen during a request to `Esplora` servers.
166165
#[derive(Debug)]
167166
pub enum Error {
168167
/// Error during `minreq` HTTP request
@@ -185,9 +184,9 @@ pub enum Error {
185184
HexToBytes(bitcoin::hex::HexToBytesError),
186185
/// Transaction not found
187186
TransactionNotFound(Txid),
188-
/// Header height not found
187+
/// Block Header height not found
189188
HeaderHeightNotFound(u32),
190-
/// Header hash not found
189+
/// Block Header hash not found
191190
HeaderHashNotFound(BlockHash),
192191
/// Invalid HTTP Header name specified
193192
InvalidHttpHeaderName(String),
@@ -220,7 +219,7 @@ impl_error!(::minreq::Error, Minreq, Error);
220219
#[cfg(feature = "async")]
221220
impl_error!(::reqwest::Error, Reqwest, Error);
222221
impl_error!(std::num::ParseIntError, Parsing, Error);
223-
impl_error!(consensus::encode::Error, BitcoinEncoding, Error);
222+
impl_error!(bitcoin::consensus::encode::Error, BitcoinEncoding, Error);
224223
impl_error!(bitcoin::hex::HexToArrayError, HexToArray, Error);
225224
impl_error!(bitcoin::hex::HexToBytesError, HexToBytes, Error);
226225

0 commit comments

Comments
 (0)