1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
//!# Systemdzbus
//!
//!Interact with systemd through DBus with a convenient rust interface.
//!All of the manager proxy types were automatically generated by the CLI tool 'zbus-xmlgen'.
//!From here I just copied the documentation from the systemd man page to
//!get good descriptions for each function.
//!
//!The plan is to gradually start wrapping each of the types into more descriptive types informed
//!by the man pages, mainly found in "man org.freedesktop.systemd1".
//!
//!## Usage
//!
//!```rust
//! use std::error::Error;
//! use systemdzbus::{SystemCtl, ConnectionLevel};
//!
//! async fn example_get_units_higher_level() -> Result<(), Box::<dyn Error>> {
//! let mut systemctl = SystemCtl::new(ConnectionLevel::UserLevel);
//! systemctl.init().await?;
//!
//! let units = systemctl.list_units().await?;
//!
//! assert!(!units.is_empty());
//! Ok(())
//! }
//!```
//!
//!You may also access the manager proxy directly if managing the connection yourself suits your
//!needs better.
//!To find out more about how to use the Connection, see the [zbus library](https://docs.rs/zbus/latest/zbus/).
//!
//!```rust
//! use std::error::Error;
//! use systemdzbus::{ManagerProxy, Connection, SystemCtl, ConnectionLevel};
//!
//! async fn example_get_units_manager_proxy() -> Result<(), Box::<dyn Error>> {
//! /// Create zbus connection. You can also use Connection::session() here.
//! let connection = Connection::system().await?;
//!
//! /// Create proxy per zbus
//! let proxy = ManagerProxy::new(&connection).await?;
//!
//! /// Use the methods on the proxy. These are the ones
//! /// that are actually documented here
//! let res = proxy.list_units().await?;
//!
//! assert!(!res.is_empty());
//!
//! /// Or you can still have your connection managed.
//! let mut systemctl = SystemCtl::new(ConnectionLevel::UserLevel);
//!
//! Ok(())
//! }
//!```
//!
//! # D-Bus interface proxy for: `org.freedesktop.systemd1.Manager`
//!
//! In terms of the ManagerProxy:
//! This code was generated by `zbus-xmlgen` `5.1.0` from D-Bus introspection data.
//! Source: `Interface '/org/freedesktop/systemd1' from service 'org.freedesktop.systemd1' on system bus`.
//!
//! More information can be found in the [Writing a client proxy] section of the zbus
//! documentation.
//!
//! This type implements the [D-Bus standard interfaces], (`org.freedesktop.DBus.*`) for which the
//! following zbus API can be used:
//!
//! [Writing a client proxy]: https://dbus2.github.io/zbus/client.html
//! [D-Bus standard interfaces]: https://dbus.freedesktop.org/doc/dbus-specification.html#standard-interfaces,
pub use ManagerProxy;
pub use ConnectionLevel;
pub use SystemCtl;
pub use SystemCtlBlocking;
pub use Connection;