systemd_run/
error.rs

1use zbus::zvariant::OwnedValue;
2
3/// The error type of `systemd_run`.
4///
5/// The various errors that can be returned by this crate.
6#[derive(Debug, thiserror::Error)]
7pub enum Error {
8    /// An error connecting to D-Bus.
9    #[error("cannot connect to dbus: {0}")]
10    DBusConnectionFail(zbus::Error),
11    /// Invalid D-Bus path.
12    #[error("cannot get a valid dbus path: {0}")]
13    DBusInvalidPath(zbus::zvariant::Error),
14    /// An error subscribing to D-Bus `PropertiesChanged` signal.
15    #[error("cannot start listening property change events: {0}")]
16    ListenPropertyChangeFail(zbus::Error),
17    /// An error parsing the changed properties from the D-Bus
18    /// `PropertiesChanged` signal.
19    #[error("cannot parse the property change event: {0}")]
20    ParsePropertyChangeFail(zbus::Error),
21    /// An error quering one property of a unit.
22    #[error("cannot query the property: {0}")]
23    QueryPropertyFail(zbus::fdo::Error),
24    /// An error calling systemd to start the transient unit.
25    #[error("cannot start the transient service: {0}")]
26    StartFail(zbus::Error),
27    /// An error attempting to calculate the time usage of a service.
28    #[error("cannot calculate {0} time usage: t0 = {1:?}, t1 = {2:?}")]
29    TimeUsageFail(&'static str, Box<OwnedValue>, Box<OwnedValue>),
30}
31
32/// Alias for a [Result][std::result::Result] with the error type [Error].
33pub type Result<T> = std::result::Result<T, Error>;