systemd_jp/
systemd_types.rs1use std::cell::RefCell;
2use std::rc::Rc;
3
4use super::*;
5
6#[ derive (Debug, Clone, Eq, PartialEq) ]
7pub enum SystemdLoadState {
8 Loaded,
9 Error,
10 Masked,
11 Other (String),
12}
13
14impl SystemdLoadState {
15
16 pub fn as_str (& self) -> & str {
17
18 match * self {
19 SystemdLoadState::Loaded => "loaded",
20 SystemdLoadState::Error => "error",
21 SystemdLoadState::Masked => "masked",
22 SystemdLoadState::Other (ref value) => value,
23 }
24
25 }
26
27}
28
29impl <'a> From <& 'a str> for SystemdLoadState {
30
31 fn from (
32 string: & str,
33 ) -> SystemdLoadState {
34
35 match string {
36 "loaded" => SystemdLoadState::Loaded,
37 "error" => SystemdLoadState::Error,
38 "masked" => SystemdLoadState::Masked,
39 other => SystemdLoadState::Other (other.to_owned ()),
40 }
41
42 }
43
44}
45
46#[ derive (Debug, Clone, Eq, PartialEq) ]
47pub enum SystemdActiveState {
48 Active,
49 Reloading,
50 Inactive,
51 Failed,
52 Activating,
53 Deactivating,
54 Other (String),
55}
56
57impl SystemdActiveState {
58
59 pub fn as_str (& self) -> & str {
60
61 match * self {
62 SystemdActiveState::Active => "active",
63 SystemdActiveState::Reloading => "reloading",
64 SystemdActiveState::Inactive => "inactive",
65 SystemdActiveState::Failed => "failed",
66 SystemdActiveState::Activating => "activating",
67 SystemdActiveState::Deactivating => "deactivating",
68 SystemdActiveState::Other (ref value) => value,
69 }
70
71 }
72
73}
74
75impl <'a> From <& 'a str> for SystemdActiveState {
76
77 fn from (
78 string: & str,
79 ) -> SystemdActiveState {
80
81 match string {
82 "active" => SystemdActiveState::Active,
83 "reloading" => SystemdActiveState::Reloading,
84 "inactive" => SystemdActiveState::Inactive,
85 "failed" => SystemdActiveState::Failed,
86 "activating" => SystemdActiveState::Activating,
87 "deactivating" => SystemdActiveState::Deactivating,
88 other => SystemdActiveState::Other (other.to_owned ()),
89 }
90
91 }
92
93}
94
95#[ derive (Debug, Clone, Eq, PartialEq) ]
96pub enum SystemdSubState {
97 Other (String),
98}
99
100impl SystemdSubState {
101
102 pub fn as_str (& self) -> & str {
103
104 match * self {
105 SystemdSubState::Other (ref value) => value,
106 }
107
108 }
109
110}
111
112impl <'a> From <& 'a str> for SystemdSubState {
113
114 fn from (
115 string: & str,
116 ) -> SystemdSubState {
117
118 match string {
119 other => SystemdSubState::Other (other.to_owned ()),
120 }
121
122 }
123
124}
125
126#[ derive (Debug, Clone, Eq, PartialEq) ]
127pub enum SystemdJobType {
128 Start,
129 VerifyActive,
130 Stop,
131 Reload,
132 Restart,
133 TryRestart,
134 ReloadOrStart,
135 Other (String),
136}
137
138impl <'a> From <& 'a str> for SystemdJobType {
139
140 fn from (
141 string: & str,
142 ) -> SystemdJobType {
143
144 match string {
145 "start" => SystemdJobType::Start,
146 "verify-active" => SystemdJobType::VerifyActive,
147 "stop" => SystemdJobType::Stop,
148 "reload" => SystemdJobType::Reload,
149 "restart" => SystemdJobType::Restart,
150 "try-restart" => SystemdJobType::TryRestart,
151 "reload-or-start" => SystemdJobType::ReloadOrStart,
152 other => SystemdJobType::Other (other.to_owned ()),
153 }
154
155 }
156
157}
158
159