Derive Macro zbus::DBusError

source ·
#[derive(DBusError)]
{
    // Attributes available to this derive:
    #[dbus_error]
}
Expand description

Derive macro for implementing zbus::DBusError trait.

This macro makes it easy to implement the zbus::DBusError trait for your custom error type (currently only enums are supported).

If a special variant marked with the dbus_error attribute is present, From<zbus::Error> is also implemented for your type. This variant can only have a single unnamed field of type zbus::Error. This implementation makes it possible for you to declare proxy methods to directly return this type, rather than zbus::Error.

Each variant (except for the special dbus_error one) can optionally have a (named or unnamed) String field (which is used as the human-readable error description).

§Example

use zbus_macros::DBusError;

#[derive(DBusError, Debug)]
#[dbus_error(prefix = "org.myservice.App")]
enum Error {
    #[dbus_error(zbus_error)]
    ZBus(zbus::Error),
    FileNotFound(String),
    OutOfMemory,
}