Skip to content

Commit

Permalink
♻️ Rename BusConfig -> Config
Browse files Browse the repository at this point in the history
  • Loading branch information
jokeyrhyme authored and zeenix committed Nov 27, 2024
1 parent dfcc35b commit ead4529
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 @@ -588,7 +588,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 @@ -600,7 +600,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 @@ -615,11 +615,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 @@ -639,7 +639,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 @@ -655,7 +655,7 @@ mod tests {
</busconfig>
"#;

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

#[test]
Expand All @@ -669,11 +669,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 @@ -708,11 +708,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 @@ -744,11 +744,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 @@ -795,11 +795,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 @@ -889,11 +889,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 @@ -939,7 +939,7 @@ mod tests {
</busconfig>
"#;

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

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

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

#[test]
Expand All @@ -969,11 +969,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 @@ -997,11 +997,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 @@ -1027,11 +1027,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 @@ -1048,11 +1048,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 @@ -1069,11 +1069,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 ead4529

Please sign in to comment.