Skip to content

Commit 27eac43

Browse files
committed
code review adjustment: reduce docs
1 parent 6194faa commit 27eac43

1 file changed

Lines changed: 8 additions & 54 deletions

File tree

bitreq/src/client.rs

Lines changed: 8 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -86,19 +86,13 @@ pub struct ClientBuilder {
8686

8787
/// Builder for configuring a `Client` with custom settings.
8888
///
89-
/// The builder allows you to set the connection pool capacity and add
90-
/// custom root certificates for TLS verification before constructing the client.
91-
///
9289
/// # Example
9390
///
9491
/// ```no_run
9592
/// # async fn example() -> Result<(), bitreq::Error> {
9693
/// use bitreq::{Client, RequestExt};
9794
///
98-
/// let cert_der = include_bytes!("../tests/test_cert.der");
99-
/// let client = Client::builder()
100-
/// .with_capacity(20)
101-
/// .build()?;
95+
/// let client = Client::builder().with_capacity(20).build()?;
10296
///
10397
/// let response = bitreq::get("https://example.com")
10498
/// .send_async_with_client(&client)
@@ -107,40 +101,16 @@ pub struct ClientBuilder {
107101
/// # }
108102
/// ```
109103
impl ClientBuilder {
110-
/// Creates a new `ClientBuilder` with default settings.
111-
///
112-
/// Default configuration:
113-
/// * `capacity` - 10 (single connection)
114-
/// * `root_certificates` - None (uses system certificates)
104+
/// Creates a new `ClientBuilder` with a default pool capacity of 10.
115105
pub fn new() -> Self { Self { capacity: 10, client_config: None } }
116106

117107
/// Sets the maximum number of connections to keep in the pool.
118-
///
119-
/// When the pool reaches this capacity, the least recently used connection
120-
/// is evicted to make room for new connections.
121-
///
122-
/// # Arguments
123-
///
124-
/// * `capacity` - Maximum number of cached connections
125-
///
126-
/// # Example
127-
///
128-
/// ```no_run
129-
/// # use bitreq::Client;
130-
/// let client = Client::builder()
131-
/// .with_capacity(10)
132-
/// .build()
133-
/// .unwrap();
134-
/// ```
135108
pub fn with_capacity(mut self, capacity: usize) -> Self {
136109
self.capacity = capacity;
137110
self
138111
}
139112

140113
/// Builds the `Client` with the configured settings.
141-
///
142-
/// Consumes the builder and returns a configured `Client` instance
143-
/// ready to send requests with connection pooling.
144114
pub fn build(self) -> Result<Client, Error> {
145115
let build = self.client_config.map(|c| c.build());
146116
let client_config = match build {
@@ -158,36 +128,20 @@ impl ClientBuilder {
158128
})),
159129
})
160130
}
161-
162-
/// Adds a custom root certificate for TLS verification.
163-
///
131+
/// Adds a custom DER-encoded root certificate for TLS verification.
164132
/// The certificate must be provided in DER format. This method accepts any type
165-
/// that can be converted into a `Vec<u8>`, such as `Vec<u8>`, `&[u8]`, or arrays.
166-
/// This is useful when connecting to servers using self-signed certificates
167-
/// or custom Certificate Authorities.
168-
///
169-
/// # Arguments
170-
///
171-
/// * `cert_der` - A DER-encoded X.509 certificate. Accepts any type that implements
172-
/// `Into<Vec<u8>>` (e.g., `&[u8]`, `Vec<u8>`, or `[u8; N]`).
133+
/// that can be converted into a `Vec<u8>`.
134+
/// The certificate is appended to the default trust store rather than replacing it.
135+
/// The trust store used depends on the TLS backend: system certificates for native-tls,
136+
/// Mozilla's root certificates(rustls-webpki) and/or system certificates(rustls-native-certs) for rustls.
173137
///
174138
/// # Example
175139
///
176140
/// ```no_run
177141
/// # use bitreq::Client;
178142
/// # async fn example() -> Result<(), bitreq::Error> {
179-
/// // Using a byte slice
180-
/// let cert_der: &[u8] = include_bytes!("../tests/test_cert.der");
181-
/// let client = Client::builder()
182-
/// .with_root_certificate(cert_der)
183-
/// .unwrap()
184-
/// .build()?;
185-
///
186-
/// // Using a Vec<u8>
187-
/// let cert_vec: Vec<u8> = cert_der.to_vec();
188143
/// let client = Client::builder()
189-
/// .with_root_certificate(cert_vec)
190-
/// .unwrap()
144+
/// .with_root_certificate(include_bytes!("../tests/test_cert.der"))?
191145
/// .build()?;
192146
/// # Ok(())
193147
/// # }

0 commit comments

Comments
 (0)