config: Move macro calls to next to the struct

This macro is kind of derive-y.  Also it has a test in it, and failing
to call it could allow bugs to exist, as well as missing bits of API.
Putting it next to the structs makes it easy to see that it's actually
been called.
This commit is contained in:
Ian Jackson 2022-05-12 15:36:56 +01:00
parent 5990df53fe
commit 400266b2c5
2 changed files with 4 additions and 9 deletions

View File

@ -57,6 +57,7 @@ pub struct ClientAddrConfig {
#[builder(default)]
pub(crate) allow_local_addrs: bool,
}
impl_default_via_builder! { ClientAddrConfig }
/// Configuration for client behavior relating to stream connection timeouts
///
@ -88,8 +89,7 @@ pub struct StreamTimeoutConfig {
#[builder_field_attr(serde(default, with = "humantime_serde::option"))]
pub(crate) resolve_ptr_timeout: Duration,
}
impl_default_via_builder! { ClientAddrConfig }
impl_default_via_builder! { StreamTimeoutConfig }
impl ClientAddrConfig {
/// Return a new [`ClientAddrConfigBuilder`].
@ -98,8 +98,6 @@ impl ClientAddrConfig {
}
}
impl_default_via_builder! { StreamTimeoutConfig }
impl StreamTimeoutConfig {
/// Return a new [`StreamTimeoutConfigBuilder`].
pub fn builder() -> StreamTimeoutConfigBuilder {
@ -148,6 +146,7 @@ pub struct StorageConfig {
#[builder(setter(into), default = "default_state_dir()")]
state_dir: CfgPath,
}
impl_default_via_builder! { StorageConfig }
/// Return the default cache directory.
fn default_cache_dir() -> CfgPath {
@ -159,8 +158,6 @@ fn default_state_dir() -> CfgPath {
CfgPath::new("${ARTI_LOCAL_DATA}".to_owned())
}
impl_default_via_builder! { StorageConfig }
impl StorageConfig {
/// Return a new StorageConfigBuilder.
pub fn builder() -> StorageConfigBuilder {
@ -272,6 +269,7 @@ pub struct TorClientConfig {
#[builder_field_attr(serde(default))]
pub(crate) stream_timeouts: StreamTimeoutConfig,
}
impl_default_via_builder! { TorClientConfig }
/// Helper to convert convert_override_net_params
fn convert_override_net_params(
@ -292,8 +290,6 @@ impl AsRef<tor_guardmgr::fallback::FallbackList> for TorClientConfig {
}
}
impl_default_via_builder! { TorClientConfig }
impl TorClientConfig {
/// Return a new TorClientConfigBuilder.
pub fn builder() -> TorClientConfigBuilder {

View File

@ -138,7 +138,6 @@ pub struct ArtiConfig {
#[builder_field_attr(serde(flatten))]
tor: TorClientConfig,
}
impl_default_via_builder! { ArtiConfig }
impl TryFrom<config::Config> for ArtiConfig {