#[derive(Debug, Clone)]
pub struct SystemdCliSpec {
pub systemctl: String,
pub journalctl: String,
pub user: bool,
pub sudo: bool,
}
#[derive(Debug, Clone)]
pub struct SystemdDbusSpec {
pub busctl: String,
pub user: bool,
pub sudo: bool,
}
impl Default for SystemdDbusSpec {
fn default() -> Self {
Self {
busctl: "busctl".to_string(),
user: false,
sudo: false,
}
}
}
impl SystemdDbusSpec {
pub fn new() -> Self {
Self::default()
}
pub fn user(mut self) -> Self {
self.user = true;
self
}
pub fn sudo(mut self) -> Self {
self.sudo = true;
self
}
pub fn busctl(mut self, binary: impl Into<String>) -> Self {
self.busctl = binary.into();
self
}
}
impl Default for SystemdCliSpec {
fn default() -> Self {
Self {
systemctl: "systemctl".to_string(),
journalctl: "journalctl".to_string(),
user: false,
sudo: false,
}
}
}
impl SystemdCliSpec {
pub fn new() -> Self {
Self::default()
}
pub fn user(mut self) -> Self {
self.user = true;
self
}
pub fn sudo(mut self) -> Self {
self.sudo = true;
self
}
pub fn systemctl(mut self, binary: impl Into<String>) -> Self {
self.systemctl = binary.into();
self
}
pub fn journalctl(mut self, binary: impl Into<String>) -> Self {
self.journalctl = binary.into();
self
}
}
#[derive(Debug, Clone)]
pub enum SystemdBackendUsed {
Cli { user: bool, sudo: bool },
Dbus {
user: bool,
sudo: bool,
busctl: String,
},
}
#[derive(Debug, Clone)]
pub struct SystemdResponse<T> {
pub backend: SystemdBackendUsed,
pub data: T,
}
impl<T> SystemdResponse<T> {
pub fn new(data: T, backend: SystemdBackendUsed) -> Self {
Self { backend, data }
}
}
#[derive(Debug, Clone)]
pub struct SystemdEmptyResponse {
pub backend: SystemdBackendUsed,
}
impl SystemdEmptyResponse {
pub fn new(backend: SystemdBackendUsed) -> Self {
Self { backend }
}
}