Skip to content

Commit

Permalink
🦺 Support <servicedir> elements
Browse files Browse the repository at this point in the history
  • Loading branch information
jokeyrhyme committed Oct 27, 2024
1 parent 7690c41 commit bcea200
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ pub struct BusConfig {
#[query(".pidfile")]
pub pidfile: Option<PathBuf>,

/// Adds a directory to search for .service files,
/// which tell the dbus-daemon how to start a program to provide a particular well-known bus name.
#[query(".servicedir")]
#[serde(default)]
pub servicedir: Vec<PathBuf>,

/// If `Some`, the bus daemon will log to syslog.
#[query(".syslog")]
// TODO: consider finding a way to make this `bool` instead of `Option<()>`
Expand Down Expand Up @@ -270,6 +276,27 @@ mod tests {
);
}

#[test]
fn bus_config_parse_with_servicedir_ok() {
let input = r#"<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-Bus Bus Configuration 1.0//EN"
"http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
<busconfig>
<servicedir>/example</servicedir>
<servicedir>/anotherexample</servicedir>
</busconfig>
"#;

let busconfig = BusConfig::parse(input).expect("should parse XML input");

assert_eq!(
busconfig,
BusConfig {
servicedir: vec![PathBuf::from("/example"), PathBuf::from("/anotherexample"),],
..Default::default()
}
);
}

#[test]
fn bus_config_parse_with_type_ok() {
let input = r#"<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-Bus Bus Configuration 1.0//EN"
Expand Down

0 comments on commit bcea200

Please sign in to comment.