1use std::path::PathBuf;
9
10use crate::fs::error::*;
11
12use crate::fs::{ControllIdentifier, ControllerInternal, Controllers, Resources, Subsystem};
13
14#[derive(Debug, Clone)]
17pub struct SystemdController {
18 base: PathBuf,
19 path: PathBuf,
20 _v2: bool,
21}
22
23impl ControllerInternal for SystemdController {
24 fn control_type(&self) -> Controllers {
25 Controllers::Systemd
26 }
27 fn get_path(&self) -> &PathBuf {
28 &self.path
29 }
30 fn get_path_mut(&mut self) -> &mut PathBuf {
31 &mut self.path
32 }
33 fn get_base(&self) -> &PathBuf {
34 &self.base
35 }
36
37 fn apply(&self, _res: &Resources) -> Result<()> {
38 Ok(())
39 }
40}
41
42impl ControllIdentifier for SystemdController {
43 fn controller_type() -> Controllers {
44 Controllers::Systemd
45 }
46}
47
48impl<'a> From<&'a Subsystem> for &'a SystemdController {
49 fn from(sub: &'a Subsystem) -> &'a SystemdController {
50 unsafe {
51 match sub {
52 Subsystem::Systemd(c) => c,
53 _ => {
54 assert_eq!(1, 0);
55 let v = std::mem::MaybeUninit::uninit();
56 v.assume_init()
57 }
58 }
59 }
60 }
61}
62
63impl SystemdController {
64 pub fn new(point: PathBuf, root: PathBuf, v2: bool) -> Self {
66 Self {
67 base: root,
68 path: point,
69 _v2: v2,
70 }
71 }
72}