From 88463ca20ebf04099b1e63353fe071aa2bc9eb26 Mon Sep 17 00:00:00 2001 From: Ron Waldon-Howe Date: Sat, 16 Nov 2024 11:18:35 +1100 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20Rename=20`BusConfig`=20->?= =?UTF-8?q?=20`Config`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://github.com/dbus2/busd/pull/159#discussion_r1842069711 --- src/config.rs | 64 +++++++++++++++++++++++++-------------------------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/src/config.rs b/src/config.rs index 65a887e..32c87f6 100644 --- a/src/config.rs +++ b/src/config.rs @@ -23,7 +23,7 @@ pub enum Access { /// /// [XML configuration files]: https://dbus.freedesktop.org/doc/dbus-daemon.1.html#configuration_file #[derive(Clone, Debug, Default, Deserialize, PartialEq)] -pub struct BusConfig { +pub struct Config { /// If `true`, connections that authenticated using the ANONYMOUS mechanism will be authorized /// to connect. This option has no practical effect unless the ANONYMOUS mechanism has also /// been enabled using the `auth` option. @@ -76,11 +76,11 @@ pub struct BusConfig { pub user: Option, } -impl TryFrom for BusConfig { +impl TryFrom for Config { type Error = Error; fn try_from(value: Document) -> std::result::Result { - let mut bc = BusConfig::default(); + let mut bc = Config::default(); for element in value.busconfig { match element { @@ -135,7 +135,7 @@ impl TryFrom for BusConfig { } } -impl BusConfig { +impl Config { pub fn limits(&self) -> Limits { match self.r#type { // For the session bus, override the default relatively-low limits with essentially @@ -590,7 +590,7 @@ mod tests { "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd"> "#; - BusConfig::parse(input).expect("should parse XML input"); + Config::parse(input).expect("should parse XML input"); } #[test] @@ -602,7 +602,7 @@ mod tests { not-a-valid-message-bus-type "#; - BusConfig::parse(input).expect("should parse XML input"); + Config::parse(input).expect("should parse XML input"); } #[test] @@ -617,11 +617,11 @@ mod tests { "#; - let busconfig = BusConfig::parse(input).expect("should parse XML input"); + let busconfig = Config::parse(input).expect("should parse XML input"); assert_eq!( busconfig, - BusConfig { + Config { allow_anonymous: true, fork: true, keep_umask: true, @@ -641,7 +641,7 @@ mod tests { "#; - let busconfig = BusConfig::parse(input).expect("should parse XML input"); + let busconfig = Config::parse(input).expect("should parse XML input"); let want = HashSet::from_iter([String::from("ANONYMOUS"), String::from("EXTERNAL")]); let diff = busconfig.auth.symmetric_difference(&want); @@ -657,7 +657,7 @@ mod tests { "#; - BusConfig::parse(input).expect("should parse XML input"); + Config::parse(input).expect("should parse XML input"); } #[test] @@ -671,11 +671,11 @@ mod tests { "#; - let busconfig = BusConfig::parse(input).expect("should parse XML input"); + let busconfig = Config::parse(input).expect("should parse XML input"); assert_eq!( busconfig, - BusConfig { + Config { listen: HashSet::from_iter(vec![ String::from("unix:path=/tmp/foo"), String::from("tcp:host=localhost,port=1234"), @@ -710,11 +710,11 @@ mod tests { "#; - let busconfig = BusConfig::parse(input).expect("should parse XML input"); + let busconfig = Config::parse(input).expect("should parse XML input"); assert_eq!( busconfig, - BusConfig { + Config { auth: HashSet::from_iter([String::from("ANONYMOUS"), String::from("EXTERNAL")]), listen: HashSet::from_iter(vec![ String::from("unix:path=/tmp/foo"), @@ -746,11 +746,11 @@ mod tests { "#; - let busconfig = BusConfig::parse(input).expect("should parse XML input"); + let busconfig = Config::parse(input).expect("should parse XML input"); assert_eq!( busconfig, - BusConfig { + Config { pidfile: Some(PathBuf::from("/var/run/busd.pid")), ..Default::default() } @@ -797,11 +797,11 @@ mod tests { "#; - let busconfig = BusConfig::parse(input).expect("should parse XML input"); + let busconfig = Config::parse(input).expect("should parse XML input"); assert_eq!( busconfig, - BusConfig { + Config { policies: vec![ Policy::DefaultContext(vec![(Access::Allow, Operation::Own),]), Policy::User( @@ -891,11 +891,11 @@ mod tests { "#; - let busconfig = BusConfig::parse(input).expect("should parse XML input"); + let busconfig = Config::parse(input).expect("should parse XML input"); assert_eq!( busconfig, - BusConfig { + Config { policies: vec![ Policy::DefaultContext(vec![ ( @@ -941,7 +941,7 @@ mod tests { "#; - BusConfig::parse(input).expect("should parse XML input"); + Config::parse(input).expect("should parse XML input"); } #[should_panic] @@ -956,7 +956,7 @@ mod tests { "#; - BusConfig::parse(input).expect("should parse XML input"); + Config::parse(input).expect("should parse XML input"); } #[test] @@ -971,11 +971,11 @@ mod tests { "#; - let busconfig = BusConfig::parse(input).expect("should parse XML input"); + let busconfig = Config::parse(input).expect("should parse XML input"); assert_eq!( busconfig, - BusConfig { + Config { servicedir: vec![ PathBuf::from("/example"), PathBuf::from("/usr/share/dbus-1/services"), @@ -999,11 +999,11 @@ mod tests { "#; - let busconfig = BusConfig::parse(input).expect("should parse XML input"); + let busconfig = Config::parse(input).expect("should parse XML input"); assert_eq!( busconfig, - BusConfig { + Config { servicedir: vec![ PathBuf::from("/example"), PathBuf::from("/usr/local/share/dbus-1/system-services"), @@ -1029,11 +1029,11 @@ mod tests { "#; - let busconfig = BusConfig::parse(input).expect("should parse XML input"); + let busconfig = Config::parse(input).expect("should parse XML input"); assert_eq!( busconfig, - BusConfig { + Config { servicehelper: Some(PathBuf::from("/anotherexample")), ..Default::default() } @@ -1050,11 +1050,11 @@ mod tests { "#; - let busconfig = BusConfig::parse(input).expect("should parse XML input"); + let busconfig = Config::parse(input).expect("should parse XML input"); assert_eq!( busconfig, - BusConfig { + Config { r#type: Some(BusType::System), ..Default::default() } @@ -1071,11 +1071,11 @@ mod tests { "#; - let busconfig = BusConfig::parse(input).expect("should parse XML input"); + let busconfig = Config::parse(input).expect("should parse XML input"); assert_eq!( busconfig, - BusConfig { + Config { user: Some(String::from("alice")), ..Default::default() }