Skip to content

Commit

Permalink
chore: Improve Debug implementation (#422)
Browse files Browse the repository at this point in the history
  • Loading branch information
0x676e67 authored Feb 10, 2025
1 parent 6e20782 commit 566a33b
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 37 deletions.
20 changes: 15 additions & 5 deletions src/client/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,19 +129,29 @@ struct Config {
impl_debug!(
Config,
{
accepts,
headers,
headers_order,
accepts,
connect_timeout,
connection_verbose,
pool_idle_timeout,
pool_max_idle_per_host,
pool_max_size,
tcp_keepalive,
proxies,
auto_sys_proxy,
redirect_policy,
accepts,
redirect_with_proxy_auth,
referer,
timeout,
connect_timeout,
https_only,
nodelay,
read_timeout,
network_scheme,
nodelay,
hickory_dns,
dns_overrides,
https_only,
http2_max_retry_count,
tls_info,
builder,
tls_config
}
Expand Down
10 changes: 10 additions & 0 deletions src/tls/cert/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,16 @@ impl RootCertStoreProvider {
}
}

impl std::fmt::Debug for RootCertStoreProvider {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
RootCertStoreProvider::Owned(_) => f.debug_tuple("Owned").finish(),
RootCertStoreProvider::Borrowed(_) => f.debug_tuple("Borrowed").finish(),
RootCertStoreProvider::Default => f.debug_tuple("Default").finish(),
}
}
}

macro_rules! impl_root_cert_store {
($($type:ty => $variant:ident),* $(,)?) => {
$(
Expand Down
33 changes: 1 addition & 32 deletions src/tls/conf.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use super::{AlpnProtos, AlpsProtos, RootCertStoreProvider, TlsVersion};
use crate::impl_debug;
use boring2::ssl::{CertCompressionAlgorithm, SslCurve};
use std::borrow::Cow;
use typed_builder::TypedBuilder;
Expand All @@ -8,7 +7,7 @@ use typed_builder::TypedBuilder;
///
/// This struct defines various parameters to fine-tune the behavior of a TLS connection,
/// including the root certificate store, certificate verification, ALPN protocols, and more.
#[derive(TypedBuilder)]
#[derive(Debug, TypedBuilder)]
pub struct TlsConfig {
/// The root certificate store.
/// Default use system's native certificate store.
Expand Down Expand Up @@ -194,36 +193,6 @@ impl Default for TlsConfig {
}
}

impl_debug!(
TlsConfig,
{
certs_verification,
tls_sni,
verify_hostname,
alpn_protos,
session_ticket,
min_tls_version,
max_tls_version,
alps_protos,
psk_dhe_ke,
pre_shared_key,
enable_ech_grease,
permute_extensions,
grease_enabled,
enable_ocsp_stapling,
renegotiation,
curves,
sigalgs_list,
cipher_list,
enable_signed_cert_timestamps,
cert_compression_algorithm,
record_size_limit,
key_shares_limit,
psk_skip_session_ticket,
extension_permutation_indices
}
);

/// A trait for converting various types into an optional `Cow` containing a slice of `CertCompressionAlgorithm`.
///
/// This trait is used to provide a unified way to convert different types
Expand Down

0 comments on commit 566a33b

Please sign in to comment.