Skip to content

Commit

Permalink
♻️ Rename BusConfig -> Config
Browse files Browse the repository at this point in the history
  • Loading branch information
jokeyrhyme committed Nov 16, 2024
1 parent 08bf221 commit 88463ca
Showing 1 changed file with 32 additions and 32 deletions.
64 changes: 32 additions & 32 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -76,11 +76,11 @@ pub struct BusConfig {
pub user: Option<String>,
}

impl TryFrom<Document> for BusConfig {
impl TryFrom<Document> for Config {
type Error = Error;

fn try_from(value: Document) -> std::result::Result<Self, Self::Error> {
let mut bc = BusConfig::default();
let mut bc = Config::default();

for element in value.busconfig {
match element {
Expand Down Expand Up @@ -135,7 +135,7 @@ impl TryFrom<Document> 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
Expand Down Expand Up @@ -590,7 +590,7 @@ mod tests {
"http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
<busconfig></busconfig>
"#;
BusConfig::parse(input).expect("should parse XML input");
Config::parse(input).expect("should parse XML input");
}

#[test]
Expand All @@ -602,7 +602,7 @@ mod tests {
<type>not-a-valid-message-bus-type</type>
</busconfig>
"#;
BusConfig::parse(input).expect("should parse XML input");
Config::parse(input).expect("should parse XML input");
}

#[test]
Expand All @@ -617,11 +617,11 @@ mod tests {
</busconfig>
"#;

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,
Expand All @@ -641,7 +641,7 @@ mod tests {
</busconfig>
"#;

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);

Expand All @@ -657,7 +657,7 @@ mod tests {
</busconfig>
"#;

BusConfig::parse(input).expect("should parse XML input");
Config::parse(input).expect("should parse XML input");
}

#[test]
Expand All @@ -671,11 +671,11 @@ mod tests {
</busconfig>
"#;

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"),
Expand Down Expand Up @@ -710,11 +710,11 @@ mod tests {
</busconfig>
"#;

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"),
Expand Down Expand Up @@ -746,11 +746,11 @@ mod tests {
</busconfig>
"#;

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()
}
Expand Down Expand Up @@ -797,11 +797,11 @@ mod tests {
</busconfig>
"#;

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(
Expand Down Expand Up @@ -891,11 +891,11 @@ mod tests {
</busconfig>
"#;

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![
(
Expand Down Expand Up @@ -941,7 +941,7 @@ mod tests {
</busconfig>
"#;

BusConfig::parse(input).expect("should parse XML input");
Config::parse(input).expect("should parse XML input");
}

#[should_panic]
Expand All @@ -956,7 +956,7 @@ mod tests {
</busconfig>
"#;

BusConfig::parse(input).expect("should parse XML input");
Config::parse(input).expect("should parse XML input");
}

#[test]
Expand All @@ -971,11 +971,11 @@ mod tests {
</busconfig>
"#;

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"),
Expand All @@ -999,11 +999,11 @@ mod tests {
</busconfig>
"#;

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"),
Expand All @@ -1029,11 +1029,11 @@ mod tests {
</busconfig>
"#;

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()
}
Expand All @@ -1050,11 +1050,11 @@ mod tests {
</busconfig>
"#;

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()
}
Expand All @@ -1071,11 +1071,11 @@ mod tests {
</busconfig>
"#;

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()
}
Expand Down

0 comments on commit 88463ca

Please sign in to comment.