tor_chanmgr/
config.rs

1//! Configuration for a channel manager (and, therefore, channels)
2//!
3//! # Semver note
4//!
5//! Most types in this module are re-exported by `arti-client`.
6
7use tor_config::impl_standard_builder;
8use tor_config::{ConfigBuildError, PaddingLevel};
9
10use derive_builder::Builder;
11use serde::{Deserialize, Serialize};
12
13/// Channel configuration
14///
15/// This type is immutable once constructed.  To build one, use
16/// [`ChannelConfigBuilder`], or deserialize it from a string.
17#[derive(Debug, Clone, Builder, Eq, PartialEq)]
18#[builder(build_fn(error = "ConfigBuildError"))]
19#[builder(derive(Debug, Serialize, Deserialize))]
20pub struct ChannelConfig {
21    /// Control of channel padding
22    #[builder(default)]
23    pub(crate) padding: PaddingLevel,
24}
25impl_standard_builder! { ChannelConfig }
26
27#[cfg(feature = "testing")]
28impl ChannelConfig {
29    /// The padding level (accessor for testing)
30    pub fn padding(&self) -> PaddingLevel {
31        self.padding
32    }
33}
34
35#[cfg(test)]
36mod test {
37    // @@ begin test lint list maintained by maint/add_warning @@
38    #![allow(clippy::bool_assert_comparison)]
39    #![allow(clippy::clone_on_copy)]
40    #![allow(clippy::dbg_macro)]
41    #![allow(clippy::mixed_attributes_style)]
42    #![allow(clippy::print_stderr)]
43    #![allow(clippy::print_stdout)]
44    #![allow(clippy::single_char_pattern)]
45    #![allow(clippy::unwrap_used)]
46    #![allow(clippy::unchecked_duration_subtraction)]
47    #![allow(clippy::useless_vec)]
48    #![allow(clippy::needless_pass_by_value)]
49    //! <!-- @@ end test lint list maintained by maint/add_warning @@ -->
50    use super::*;
51
52    #[test]
53    fn channel_config() {
54        let config = ChannelConfig::default();
55
56        assert_eq!(PaddingLevel::Normal, config.padding);
57    }
58}