Skip to content

Commit

Permalink
examples/systemd-start-service: tweak to build when bus disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
codyps committed Dec 14, 2021
1 parent eaa0581 commit b43332f
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions examples/systemd-start-service.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
use std::ops::Deref;

use utf8_cstr::Utf8CStr;

#![warn(rust_2018_idioms)]
// WARNING: you may want to use a more tested/complete dbus library, or one that is pure rust.
// `zbus` may be a reasonable choice, and there are others too

use utf8_cstr::Utf8CStr;
// approximately this command:
// busctl --system call org.freedesktop.systemd1 /org/freedesktop/systemd1 org.freedesktop.systemd1.Manager StartUnit "ss" "foo.service" "fail"
#[cfg(feature = "bus")]
fn main() {
let mut bus = systemd::bus::Bus::default_system().unwrap();

Expand All @@ -29,5 +28,10 @@ fn main() {

let res = method_call.call(0).unwrap();

eprintln!("done, result={:?}", res.deref());
eprintln!("done, result={:?}", *res);
}

#[cfg(not(feature = "bus"))]
fn main() {
println!("bus disabled");
}

0 comments on commit b43332f

Please sign in to comment.