tokio-dbus 0.2.0

Pure Rust D-Bus implementation for Tokio.
Documentation
//! Types associated with the `org.freedesktop.DBus` interface.

use crate::ObjectPath;

/// Well known destination name.
pub const DESTINATION: &str = "org.freedesktop.DBus";

/// Well known interface name.
pub const INTERFACE: &str = "org.freedesktop.DBus";

/// The standard interface through which properties of an object are read and
/// written.
pub const PROPERTIES_INTERFACE: &str = "org.freedesktop.DBus.Properties";

/// The standard interface through which the interfaces implemented by an object
/// are described as XML.
pub const INTROSPECTABLE_INTERFACE: &str = "org.freedesktop.DBus.Introspectable";

/// The standard interface implemented by every peer on a connection.
pub const PEER_INTERFACE: &str = "org.freedesktop.DBus.Peer";

/// Well known D-Bus path.
pub const PATH: &ObjectPath = ObjectPath::new_const(b"/org/freedesktop/DBus");

/// The error raised when a message is sent to an object which does not exist.
pub const UNKNOWN_OBJECT_ERROR: &str = "org.freedesktop.DBus.Error.UnknownObject";

/// The error raised when a message names an interface which is not implemented.
pub const UNKNOWN_INTERFACE_ERROR: &str = "org.freedesktop.DBus.Error.UnknownInterface";

/// The error raised when a message names a method which does not exist.
pub const UNKNOWN_METHOD_ERROR: &str = "org.freedesktop.DBus.Error.UnknownMethod";

/// The error raised when a message names a property which does not exist.
pub const UNKNOWN_PROPERTY_ERROR: &str = "org.freedesktop.DBus.Error.UnknownProperty";

/// The error raised when the arguments of a message are not the ones expected.
pub const INVALID_ARGS_ERROR: &str = "org.freedesktop.DBus.Error.InvalidArgs";

/// A generic error, used when no more specific error applies.
pub const FAILED_ERROR: &str = "org.freedesktop.DBus.Error.Failed";

/// The error raised when a method call did not receive a reply, such as when
/// it timed out.
pub const NO_REPLY_ERROR: &str = "org.freedesktop.DBus.Error.NoReply";

/// The error raised when a destination name has no owner and could not be
/// activated.
pub const SERVICE_UNKNOWN_ERROR: &str = "org.freedesktop.DBus.Error.ServiceUnknown";

/// The error raised when a name which was asked about has no owner.
pub const NAME_HAS_NO_OWNER_ERROR: &str = "org.freedesktop.DBus.Error.NameHasNoOwner";

/// The error raised when a security policy refuses an operation, most commonly
/// on the system bus.
pub const ACCESS_DENIED_ERROR: &str = "org.freedesktop.DBus.Error.AccessDenied";

/// The error raised when a method exists but is not supported where it was
/// called.
pub const NOT_SUPPORTED_ERROR: &str = "org.freedesktop.DBus.Error.NotSupported";

raw_set! {
    /// The flags to a `RequestName` call.
    #[repr(u32)]
    pub enum NameFlag {
        /// If an application A specifies this flag and succeeds in becoming the
        /// owner of the name, and another application B later calls
        /// `RequestName` with the `REPLACE_EXISTING` flag, then application A
        /// will lose ownership and receive a `org.freedesktop.DBus.NameLost`
        /// signal, and application B will become the new owner. If
        /// `ALLOW_REPLACEMENT` is not specified by application A, or
        /// `REPLACE_EXISTING` is not specified by application B, then
        /// application B will not replace application A as the owner.
        ALLOW_REPLACEMENT = 1,
        /// Try to replace the current owner if there is one. If this flag is
        /// not set the application will only become the owner of the name if
        /// there is no current owner. If this flag is set, the application will
        /// replace the current owner if the current owner specified
        /// `ALLOW_REPLACEMENT`.
        REPLACE_EXISTING = 2,
        /// Without this flag, if an application requests a name that is already
        /// owned, the application will be placed in a queue to own the name
        /// when the current owner gives it up. If this flag is given, the
        /// application will not be placed in the queue, the request for the
        /// name will simply fail. This flag also affects behavior when an
        /// application is replaced as name owner; by default the application
        /// moves back into the waiting queue, unless this flag was provided
        /// when the application became the name owner.
        DO_NOT_QUEUE = 4,
    }
}

raw_enum! {
    /// The reply to a `RequestName` call.
    #[repr(u32)]
    pub enum NameReply {
        /// The caller is now the primary owner of the name, replacing any
        /// previous owner. Either the name had no owner before, or the caller
        /// specified [`NameFlag::REPLACE_EXISTING`] and the current owner
        /// specified [`NameFlag::ALLOW_REPLACEMENT`].
        PRIMARY_OWNER = 1,
        /// The name already had an owner, [`NameFlag::DO_NOT_QUEUE`] was not
        /// specified, and either the current owner did not specify
        /// [`NameFlag::ALLOW_REPLACEMENT`] or the requesting application did
        /// not specify [`NameFlag::REPLACE_EXISTING`].
        IN_QUEUE = 2,
        /// The name already has an owner, [`NameFlag::DO_NOT_QUEUE`] was
        /// specified, and either [`NameFlag::ALLOW_REPLACEMENT`] was not
        /// specified by the current owner, or [`NameFlag::REPLACE_EXISTING`]
        /// was not specified by the requesting application.
        EXISTS = 3,
        /// The application trying to request ownership of a name is already the
        /// owner of it.
        ALREADY_OWNER = 4,
    }
}