DBusError

Derive Macro DBusError 

Source
#[derive(DBusError)]
{
    // Attributes available to this derive:
    #[zbus]
}
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 zbus 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 zbus one) can optionally have a (named or unnamed) String field (which is used as the human-readable error description).

The following type-level attributes are supported:

  • prefix - the D-Bus error name prefix.
  • crate - specify the path to the zbus crate if it’s renamed or re-exported.

§Example

use zbus::DBusError;

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