1use serde::{Deserialize, Serialize};
2use zbus::zvariant::{OwnedObjectPath, OwnedValue, Type, Value};
3
4use crate::{enum_impl_serde_str, enum_impl_str_conv, impl_value_conversions_as_str};
5
6#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Clone, Copy, Type)]
7pub enum UnitType {
8 Service,
9 Mount,
10 Swap,
11 Socket,
12 Target,
13 Device,
14 Automount,
15 Timer,
16 Path,
17 Slice,
18 Scope,
19}
20
21enum_impl_str_conv!(UnitType, {
22 "service": Service,
23 "mount": Mount,
24 "swap": Swap,
25 "socket": Socket,
26 "target": Target,
27 "device": Device,
28 "automount": Automount,
29 "timer": Timer,
30 "path": Path,
31 "slice": Slice,
32 "scope": Scope,
33});
34enum_impl_serde_str!(UnitType);
35impl_value_conversions_as_str!(UnitType);
36
37#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Clone, Copy, Type, Serialize, Deserialize)]
38pub enum UnitFileFlags {
39 Runtime,
43 Force,
47 Portable,
51}
52
53#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Clone, Copy, Type)]
54#[zvariant(signature = "s")]
55pub enum Mode {
56 Replace,
57 Fail,
58 Isolate,
59 IgnoreDependencies,
60 IgnoreRequirements,
61}
62
63enum_impl_str_conv!(Mode, {
64 "replace": Replace,
65 "fail": Fail,
66 "isolate": Isolate,
67 "ignore-dependencies": IgnoreDependencies,
68 "ignore-requirements": IgnoreRequirements,
69});
70enum_impl_serde_str!(Mode);
71impl_value_conversions_as_str!(Mode);
72
73#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Clone, Copy, Type)]
74#[zvariant(signature = "s")]
75pub enum LoadState {
76 Stub,
77 Loaded,
78 NotFound,
79 BadSetting,
80 Error,
81 Merged,
82 Masked,
83}
84
85enum_impl_str_conv!(LoadState, {
86 "stub": Stub,
87 "loaded": Loaded,
88 "not-found": NotFound,
89 "bad-setting": BadSetting,
90 "error": Error,
91 "merged": Merged,
92 "masked": Masked,
93});
94enum_impl_serde_str!(LoadState);
95impl_value_conversions_as_str!(LoadState);
96
97#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Clone, Copy, Type)]
98#[zvariant(signature = "s")]
99pub enum ActiveState {
100 Active,
101 Reloading,
102 Inactive,
103 Failed,
104 Activating,
105 Deactivating,
106 Maintenance,
107}
108
109enum_impl_str_conv!(ActiveState, {
110 "active": Active,
111 "reloading": Reloading,
112 "inactive": Inactive,
113 "failed": Failed,
114 "activating": Activating,
115 "deactivating": Deactivating,
116 "maintenance" : Maintenance,
117});
118enum_impl_serde_str!(ActiveState);
119impl_value_conversions_as_str!(ActiveState);
120
121#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Clone, Copy, Type)]
122#[zvariant(signature = "s")]
123pub enum UnitFileState {
124 Enabled,
125 EnabledRuntime,
126 Linked,
127 LinkedRuntime,
128 Masked,
129 MaskedRuntime,
130 Static,
131 Disabled,
132 Invalid,
133}
134
135enum_impl_str_conv!(UnitFileState, {
136 "enabled": Enabled,
137 "enabled-runtime": EnabledRuntime,
138 "linked": Linked,
139 "linked-runtime": LinkedRuntime,
140 "masked": Masked,
141 "masked-runtime": MaskedRuntime,
142 "static": Static,
143 "disabled": Disabled,
144 "invalid": Invalid,
145
146});
147enum_impl_serde_str!(UnitFileState);
148impl_value_conversions_as_str!(UnitFileState);
149
150#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Clone, Copy, Type)]
156#[zvariant(signature = "s")]
157pub enum SubState {
158 Dead,
159 Waiting,
160 Running,
161 Failed,
162 Tentative,
163 Plugged,
164 Mounting,
165 MountingDone,
166 Mounted,
167 Remounting,
168 Unmounting,
169 RemountingSigterm,
170 RemountingSigkill,
171 UnmountingSigterm,
172 UnmountingSigkill,
173 Cleaning,
174 Abandoned,
175 StopSigterm,
176 StopSigkill,
177 Condition,
178 StartPre,
179 Start,
180 StartPost,
181 Exited,
182 Reload,
183 Stop,
184 StopWatchdog,
185 StopPost,
186 FinalWatchdog,
187 FinalSigterm,
188 FinalSigkill,
189 AutoRestart,
190 AutoRestartQueued,
191 Active,
192 StartChown,
193 Listening,
194 StopPre,
195 StopPreSigterm,
196 StopPreSigkill,
197 Activating,
198 ActivatingDone,
199 Deactivating,
200 DeactivatingSigterm,
201 DeactivatingSigkill,
202 Elapsed,
203}
204
205enum_impl_str_conv!(SubState, {
206 "dead": Dead,
207 "waiting": Waiting,
208 "running": Running,
209 "failed": Failed,
210 "tentative": Tentative,
211 "plugged": Plugged,
212 "mounting": Mounting,
213 "mounting-done": MountingDone,
214 "mounted": Mounted,
215 "remounting": Remounting,
216 "unmounting": Unmounting,
217 "remounting-sigterm": RemountingSigterm,
218 "remounting-sigkill": RemountingSigkill,
219 "unmounting-sigterm": UnmountingSigterm,
220 "unmounting-sigkill": UnmountingSigkill,
221 "cleaning": Cleaning,
222 "abandoned": Abandoned,
223 "stop-sigterm": StopSigterm,
224 "stop-sigkill": StopSigkill,
225 "condition": Condition,
226 "start-pre": StartPre,
227 "start": Start,
228 "start-post": StartPost,
229 "exited": Exited,
230 "reload": Reload,
231 "stop": Stop,
232 "stop-watchdog": StopWatchdog,
233 "stop-post": StopPost,
234 "final-watchdog": FinalWatchdog,
235 "final-sigterm": FinalSigterm,
236 "final-sigkill": FinalSigkill,
237 "auto-restart": AutoRestart,
238 "auto-restart-queued": AutoRestartQueued,
239 "active": Active,
240 "start-chown": StartChown,
241 "listening": Listening,
242 "stop-pre": StopPre,
243 "stop-pre-sigterm": StopPreSigterm,
244 "stop-pre-sigkill": StopPreSigkill,
245 "activating": Activating,
246 "activating-done": ActivatingDone,
247 "deactivating": Deactivating,
248 "deactivating-sigterm": DeactivatingSigterm,
249 "deactivating-sigkill": DeactivatingSigkill,
250 "elapsed": Elapsed,
251});
252enum_impl_serde_str!(SubState);
253impl_value_conversions_as_str!(SubState);
254
255#[derive(Debug, PartialEq, Eq, Clone, Type, Serialize, Deserialize)]
256pub struct Unit {
257 pub name: String,
259 pub description: String,
261 pub load: LoadState,
263 pub active: ActiveState,
265 pub sub_state: SubState,
267 pub followed_unit: String,
269 pub path: OwnedObjectPath,
271 pub queued_job: u32,
273 pub job_type: String,
275 pub job_path: OwnedObjectPath,
277}
278
279#[derive(Debug, PartialEq, Eq, Clone, Type, Serialize, Deserialize)]
280pub struct Job {
281 pub job_id: u32,
283 pub unit_name: String,
285 pub job_type: JobType,
287 pub job_state: JobState,
289 pub job_path: OwnedObjectPath,
291 pub unit_path: OwnedObjectPath,
293}
294
295#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Clone, Copy, Type)]
297#[zvariant(signature = "s")]
298pub enum JobType {
299 Start,
300 VerifyActive,
301 Stop,
302 Reload,
303 Restart,
304 TryRestart,
305 ReloadOrStart,
306}
307enum_impl_str_conv!(JobType, {
308 "start": Start,
309 "verify-active": VerifyActive,
310 "stop": Stop,
311 "reload": Reload,
312 "restart": Restart,
313 "try-restart": TryRestart,
314 "reload-or-start": ReloadOrStart,
315});
316enum_impl_serde_str!(JobType);
317impl_value_conversions_as_str!(JobType);
318
319#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Clone, Copy, Type)]
321#[zvariant(signature = "s")]
322pub enum JobState {
323 Waiting,
325
326 Running,
328}
329enum_impl_str_conv!(JobState, {
330 "waiting": Waiting,
331 "running": Running,
332});
333enum_impl_serde_str!(JobState);
334impl_value_conversions_as_str!(JobState);
335
336#[derive(Debug, PartialEq, Eq, Clone, Type, Serialize, Deserialize)]
337pub struct EnquedJob {
338 pub job_id: u32,
340 pub job_path: OwnedObjectPath,
342 pub unit_name: String,
344 pub unit_path: OwnedObjectPath,
346 pub job_type: String,
348}
349
350#[derive(Debug, PartialEq, Eq, Clone, Type, Serialize, Deserialize)]
351pub struct EnqueJob {
352 pub job: EnquedJob,
353 pub affected_jobs: Vec<EnquedJob>,
354}
355
356#[derive(Debug, PartialEq, Eq, Clone, Type, Serialize, Deserialize, Value, OwnedValue)]
357pub struct KeyValue<K, V>
358where
359 K: Type,
360 V: Type,
361{
362 pub key: K,
364
365 pub value: V,
367}
368
369#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Clone, Copy, Type)]
370#[zvariant(signature = "s")]
371pub enum ChangeType {
372 Symlink,
373 Unlink,
374}
375
376enum_impl_str_conv!(ChangeType, {
377 "symlink": Symlink,
378 "unlink": Unlink,
379});
380enum_impl_serde_str!(ChangeType);
381impl_value_conversions_as_str!(ChangeType);
382
383#[derive(Debug, PartialEq, Eq, Clone, Type, Serialize, Deserialize)]
384pub struct Change {
385 change_type: ChangeType,
386 symlink_file: String,
388 symlink_dest: String,
390}
391
392#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Clone, Copy, Type)]
394#[zvariant(signature = "s")]
395pub enum PathWatchCondition {
396 Exists,
397 ExistsGlob,
398 Changed,
399 Modified,
400 DirectoryNotEmpty,
401}
402enum_impl_str_conv!(PathWatchCondition, {
403 "PathExists": Exists,
404 "PathExistsGlob": ExistsGlob,
405 "PathChanged": Changed,
406 "PathModified": Modified,
407 "PathDirectoryNotEmpty": DirectoryNotEmpty,
408});
409enum_impl_serde_str!(PathWatchCondition);
410impl_value_conversions_as_str!(PathWatchCondition);
411
412#[derive(Debug, PartialEq, Eq, Clone, Type, Serialize, Deserialize, Value, OwnedValue)]
414pub struct PathWatch {
415 pub condition: String, pub path: String,
423}
424
425#[derive(Debug, PartialEq, Eq, Clone, Type, Serialize, Deserialize, Value, OwnedValue)]
427pub struct Exec {
428 pub binary_path: String,
430
431 pub arguments: Vec<String>,
433
434 pub is_failure: bool,
436
437 pub last_start_realtime_us: u64,
439
440 pub last_start_monotonic_us: u64,
442
443 pub last_exit_realtime_us: u64,
445
446 pub last_exit_monotonic_us: u64,
448
449 pub pid: u32,
451
452 pub last_exit_code: i32,
454
455 pub last_status: i32,
457}
458
459#[derive(Debug, PartialEq, Eq, Clone, Type, Serialize, Deserialize, Value, OwnedValue)]
461pub struct ExecEx {
462 pub binary_path: String,
464
465 pub arguments: Vec<String>,
467
468 pub options: Vec<String>,
479
480 pub last_start_realtime_us: u64,
482
483 pub last_start_monotonic_us: u64,
485
486 pub last_exit_realtime_us: u64,
488
489 pub last_exit_monotonic_us: u64,
491
492 pub pid: u32,
494
495 pub last_exit_code: i32,
497
498 pub last_status: i32,
500}
501
502#[derive(Debug, PartialEq, Eq, Clone, Type, Serialize, Deserialize, Value, OwnedValue)]
504pub struct TimerCalendar {
505 pub base: String, pub calendar_spec: String,
510
511 pub next_elapse_realtime_usec: u64,
513}
514
515#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Clone, Copy, Type)]
517#[zvariant(signature = "s")]
518pub enum TimerCalendarBase {
519 OnCalendar,
520}
521enum_impl_str_conv!(TimerCalendarBase, {
522 "OnCalendar": OnCalendar,
523});
524enum_impl_serde_str!(TimerCalendarBase);
525impl_value_conversions_as_str!(TimerCalendarBase);
526
527#[derive(Debug, PartialEq, Eq, Clone, Type, Serialize, Deserialize, Value, OwnedValue)]
529pub struct TimerMonotonic {
530 pub base: String, pub offset_usec: u64,
535
536 pub next_elapse_realtime_usec: u64,
538}
539
540#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Clone, Copy, Type)]
542#[zvariant(signature = "s")]
543pub enum TimerMonotonicBase {
544 OnActiveUSec,
545 OnBootUSec,
546 OnStartupUSec,
547 OnUnitActiveUSec,
548 OnUnitInactiveUSec,
549}
550enum_impl_str_conv!(TimerMonotonicBase, {
551 "OnActiveUSec": OnActiveUSec,
552 "OnBootUSec": OnBootUSec,
553 "OnStartupUSec": OnStartupUSec,
554 "OnUnitActiveUSec": OnUnitActiveUSec,
555 "OnUnitInactiveUSec": OnUnitInactiveUSec,
556});
557enum_impl_serde_str!(TimerMonotonicBase);
558impl_value_conversions_as_str!(TimerMonotonicBase);
559
560pub const BIND_MOUNT_RECURSIVE: u64 = 0x4000;
562
563#[derive(Debug, PartialEq, Eq, Clone, Type, Serialize, Deserialize, Value, OwnedValue)]
564pub struct BindMount {
565 pub source: String,
567
568 pub destination: String,
570
571 pub ignore_non_existing: bool,
573
574 pub options: u64,
578}
579
580#[derive(Debug, PartialEq, Eq, Clone, Type, Serialize, Deserialize, Value, OwnedValue)]
582pub struct Process {
583 pub cgroup_controller: String,
585
586 pub pid: u32,
588
589 pub command_line: String,
591}
592
593#[derive(Debug, PartialEq, Eq, Clone, Type, Serialize, Deserialize, Value, OwnedValue)]
595pub struct DirectorySymlink {
596 pub target_path: String,
598
599 pub symlink_path: String,
601
602 pub flags: u64,
604}
605
606#[derive(Debug, PartialEq, Eq, Clone, Type, Serialize, Deserialize, Value, OwnedValue)]
608pub struct MountImage {
609 pub image_path: String,
611
612 pub mount_point: String,
614
615 pub ignore_non_existing: bool,
617
618 pub mount_options: Vec<PartitionMountOptions>,
620}
621
622#[derive(Debug, PartialEq, Eq, Clone, Type, Serialize, Deserialize, Value, OwnedValue)]
624pub struct PartitionMountOptions {
625 pub partition: String,
627
628 pub mount_options: String,
630}
631
632#[derive(Debug, PartialEq, Eq, Clone, Type, Serialize, Deserialize, Value, OwnedValue)]
634pub struct ExtensionImage {
635 pub image_path: String,
637
638 pub ignore_non_existing: bool,
640
641 pub mount_options: Vec<PartitionMountOptions>,
643}