Skip to content

Commit f4864f0

Browse files
committed
chore(docs): add minor improvements on docs
- standardize dependencies on `Cargo.toml`, and sort it. - add a couple of documentation improvements, on missing docstring fields.
1 parent 6002aea commit f4864f0

File tree

5 files changed

+26
-21
lines changed

5 files changed

+26
-21
lines changed

Cargo.toml

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,26 +17,28 @@ name = "esplora_client"
1717
path = "src/lib.rs"
1818

1919
[dependencies]
20-
serde = { version = "1.0", features = ["derive"] }
2120
bitcoin = { version = "0.32", features = ["serde", "std"], default-features = false }
22-
hex = { package = "hex-conservative", version = "0.2" }
23-
log = "^0.4"
21+
hex = { version = "0.2", package = "hex-conservative" }
22+
log = { version = "^0.4" }
2423
minreq = { version = "2.11.0", features = ["json-using-serde"], optional = true }
25-
reqwest = { version = "0.11", optional = true, default-features = false, features = ["json"] }
24+
reqwest = { version = "0.11", features = ["json"], default-features = false, optional = true }
25+
serde = { version = "1.0", features = ["derive"] }
2626

2727
[dev-dependencies]
28-
serde_json = "1.0"
29-
tokio = { version = "1.20.1", features = ["full"] }
3028
electrsd = { version = "0.28.0", features = ["legacy", "esplora_a33e97e1", "bitcoind_25_0"] }
31-
lazy_static = "1.4.0"
29+
lazy_static = { version = "1.4.0"}
30+
serde_json = { version = "1.0"}
31+
tokio = { version = "1.20.1", features = ["full"] }
3232

3333
[features]
3434
default = ["blocking", "async", "async-https"]
35+
3536
blocking = ["minreq", "minreq/proxy"]
3637
blocking-https = ["blocking", "minreq/https"]
3738
blocking-https-rustls = ["blocking", "minreq/https-rustls"]
3839
blocking-https-native = ["blocking", "minreq/https-native"]
3940
blocking-https-bundled = ["blocking", "minreq/https-bundled"]
41+
4042
async = ["reqwest", "reqwest/socks"]
4143
async-https = ["async", "reqwest/default-tls"]
4244
async-https-native = ["async", "reqwest/native-tls"]

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: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
//! capabilities using the platform's native TLS backend (likely OpenSSL).
5353
//! * `blocking-https-bundled` enables [`minreq`], the blocking client with proxy and TLS (SSL)
5454
//! capabilities using a bundled OpenSSL library backend.
55+
//!
5556
//! * `async` enables [`reqwest`], the async client with proxy capabilities.
5657
//! * `async-https` enables [`reqwest`], the async client with support for proxying and TLS (SSL)
5758
//! using the default [`reqwest`] TLS backend.
@@ -71,8 +72,6 @@ use std::collections::HashMap;
7172
use std::fmt;
7273
use std::num::TryFromIntError;
7374

74-
use bitcoin::consensus;
75-
7675
pub mod api;
7776

7877
#[cfg(feature = "async")]
@@ -103,6 +102,7 @@ pub fn convert_fee_rate(target: usize, estimates: HashMap<u16, f64>) -> Result<f
103102

104103
#[derive(Debug, Clone)]
105104
pub struct Builder {
105+
/// The URL of the Esplora server.
106106
pub base_url: String,
107107
/// Optional URL of the proxy to use to make requests to the Esplora server
108108
///
@@ -117,7 +117,7 @@ pub struct Builder {
117117
pub proxy: Option<String>,
118118
/// Socket timeout.
119119
pub timeout: Option<u64>,
120-
/// HTTP headers to set on every request made to Esplora server
120+
/// HTTP headers to set on every request made to Esplora server.
121121
pub headers: HashMap<String, String>,
122122
}
123123

@@ -150,20 +150,20 @@ impl Builder {
150150
self
151151
}
152152

153-
/// build a blocking client from builder
153+
/// Build a blocking client from builder
154154
#[cfg(feature = "blocking")]
155155
pub fn build_blocking(self) -> BlockingClient {
156156
BlockingClient::from_builder(self)
157157
}
158158

159-
// build an asynchronous client from builder
159+
// Build an asynchronous client from builder
160160
#[cfg(feature = "async")]
161161
pub fn build_async(self) -> Result<AsyncClient, Error> {
162162
AsyncClient::from_builder(self)
163163
}
164164
}
165165

166-
/// Errors that can happen during a sync with `Esplora`
166+
/// Errors that can happen during a request to `Esplora` servers.
167167
#[derive(Debug)]
168168
pub enum Error {
169169
/// Error during `minreq` HTTP request
@@ -186,9 +186,9 @@ pub enum Error {
186186
HexToBytes(bitcoin::hex::HexToBytesError),
187187
/// Transaction not found
188188
TransactionNotFound(Txid),
189-
/// Header height not found
189+
/// Block Header height not found
190190
HeaderHeightNotFound(u32),
191-
/// Header hash not found
191+
/// Block Header hash not found
192192
HeaderHashNotFound(BlockHash),
193193
/// Invalid HTTP Header name specified
194194
InvalidHttpHeaderName(String),
@@ -221,7 +221,7 @@ impl_error!(::minreq::Error, Minreq, Error);
221221
#[cfg(feature = "async")]
222222
impl_error!(::reqwest::Error, Reqwest, Error);
223223
impl_error!(std::num::ParseIntError, Parsing, Error);
224-
impl_error!(consensus::encode::Error, BitcoinEncoding, Error);
224+
impl_error!(bitcoin::consensus::encode::Error, BitcoinEncoding, Error);
225225
impl_error!(bitcoin::hex::HexToArrayError, HexToArray, Error);
226226
impl_error!(bitcoin::hex::HexToBytesError, HexToBytes, Error);
227227

0 commit comments

Comments
 (0)