in crates/zbus/src/fdo.rs [443:706]
fn get_stats(&self) -> Result<Vec<HashMap<String, OwnedValue>>>;
/// GetConnectionStats (undocumented)
fn get_connection_stats(&self, name: BusName<'_>) -> Result<Vec<HashMap<String, OwnedValue>>>;
/// GetAllMatchRules (undocumented)
fn get_all_match_rules(&self) ->
Result<
Vec<
HashMap<
crate::names::OwnedUniqueName,
Vec<crate::OwnedMatchRule>,
>
>
>;
}
};
}
gen_stats_proxy!(true, false);
assert_impl_all!(StatsProxy<'_>: Send, Sync, Unpin);
/// The flags used by the bus [`request_name`] method.
///
/// [`request_name`]: struct.DBusProxy.html#method.request_name
#[bitflags]
#[repr(u32)]
#[derive(Type, Debug, PartialEq, Eq, Copy, Clone, Serialize, Deserialize)]
pub enum RequestNameFlags {
/// If an application A specifies this flag and succeeds in becoming the owner of the name, and
/// another application B later calls [`request_name`] with the [`ReplaceExisting`] flag, then
/// application A will lose ownership and receive a `org.freedesktop.DBus.NameLost` signal, and
/// application B will become the new owner. If [`AllowReplacement`] is not specified by
/// application A, or [`ReplaceExisting`] is not specified by application B, then application B
/// will not replace application A as the owner.
///
/// [`ReplaceExisting`]: enum.RequestNameFlags.html#variant.ReplaceExisting
/// [`AllowReplacement`]: enum.RequestNameFlags.html#variant.AllowReplacement
/// [`request_name`]: struct.DBusProxy.html#method.request_name
AllowReplacement = 0x01,
/// 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
/// [`AllowReplacement`].
///
/// [`AllowReplacement`]: enum.RequestNameFlags.html#variant.AllowReplacement
ReplaceExisting = 0x02,
/// 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.
DoNotQueue = 0x04,
}
assert_impl_all!(RequestNameFlags: Send, Sync, Unpin);
/// The return code of the [`request_name`] method.
///
/// [`request_name`]: struct.DBusProxy.html#method.request_name
#[repr(u32)]
#[derive(Deserialize_repr, Serialize_repr, Type, Debug, PartialEq, Eq)]
pub enum RequestNameReply {
/// 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 [`ReplaceExisting`] and the current owner
/// specified [`AllowReplacement`].
///
/// [`ReplaceExisting`]: enum.RequestNameFlags.html#variant.ReplaceExisting
/// [`AllowReplacement`]: enum.RequestNameFlags.html#variant.AllowReplacement
PrimaryOwner = 0x01,
/// The name already had an owner, [`DoNotQueue`] was not specified, and either the current
/// owner did not specify [`AllowReplacement`] or the requesting application did not specify
/// [`ReplaceExisting`].
///
/// [`DoNotQueue`]: enum.RequestNameFlags.html#variant.DoNotQueue
/// [`ReplaceExisting`]: enum.RequestNameFlags.html#variant.ReplaceExisting
/// [`AllowReplacement`]: enum.RequestNameFlags.html#variant.AllowReplacement
InQueue = 0x02,
/// The name already had an owner, [`DoNotQueue`] was specified, and either
/// [`AllowReplacement`] was not specified by the current owner, or [`ReplaceExisting`] was
/// not specified by the requesting application.
///
/// [`DoNotQueue`]: enum.RequestNameFlags.html#variant.DoNotQueue
/// [`ReplaceExisting`]: enum.RequestNameFlags.html#variant.ReplaceExisting
/// [`AllowReplacement`]: enum.RequestNameFlags.html#variant.AllowReplacement
Exists = 0x03,
/// The application trying to request ownership of a name is already the owner of it.
AlreadyOwner = 0x04,
}
assert_impl_all!(RequestNameReply: Send, Sync, Unpin);
/// The return code of the [`release_name`] method.
///
/// [`release_name`]: struct.DBusProxy.html#method.release_name
#[repr(u32)]
#[derive(Deserialize_repr, Serialize_repr, Type, Debug, PartialEq, Eq)]
pub enum ReleaseNameReply {
/// The caller has released their claim on the given name. Either the caller was the primary
/// owner of the name, and the name is now unused or taken by somebody waiting in the queue for
/// the name, or the caller was waiting in the queue for the name and has now been removed from
/// the queue.
Released = 0x01,
/// The given name does not exist on this bus.
NonExistent = 0x02,
/// The caller was not the primary owner of this name, and was also not waiting in the queue to
/// own this name.
NotOwner = 0x03,
}
assert_impl_all!(ReleaseNameReply: Send, Sync, Unpin);
/// Credentials of a process connected to a bus server.
///
/// If unable to determine certain credentials (for instance, because the process is not on the same
/// machine as the bus daemon, or because this version of the bus daemon does not support a
/// particular security framework), or if the values of those credentials cannot be represented as
/// documented here, then those credentials are omitted.
///
/// **Note**: unknown keys, in particular those with "." that are not from the specification, will
/// be ignored. Use your own implementation or contribute your keys here, or in the specification.
#[derive(Debug, Default, DeserializeDict, PartialEq, Eq, SerializeDict, Type)]
#[zvariant(signature = "a{sv}")]
pub struct ConnectionCredentials {
#[zvariant(rename = "UnixUserID")]
pub(crate) unix_user_id: Option<u32>,
#[zvariant(rename = "UnixGroupIDs")]
pub(crate) unix_group_ids: Option<Vec<u32>>,
#[zvariant(rename = "ProcessID")]
pub(crate) process_id: Option<u32>,
#[zvariant(rename = "WindowsSID")]
pub(crate) windows_sid: Option<String>,
#[zvariant(rename = "LinuxSecurityLabel")]
pub(crate) linux_security_label: Option<Vec<u8>>,
}
impl ConnectionCredentials {
/// The numeric Unix user ID, as defined by POSIX.
pub fn unix_user_id(&self) -> Option<u32> {
self.unix_user_id
}
/// The numeric Unix group IDs (including both the primary group and the supplementary groups),
/// as defined by POSIX, in numerically sorted order. This array is either complete or absent:
/// if the message bus is able to determine some but not all of the caller's groups, or if one
/// of the groups is not representable in a UINT32, it must not add this credential to the
/// dictionary.
pub fn unix_group_ids(&self) -> Option<&Vec<u32>> {
self.unix_group_ids.as_ref()
}
/// Same as [`ConnectionCredentials::unix_group_ids`], but consumes `self` and returns the group
/// IDs Vec.
pub fn into_unix_group_ids(self) -> Option<Vec<u32>> {
self.unix_group_ids
}
/// The numeric process ID, on platforms that have this concept. On Unix, this is the process ID
/// defined by POSIX.
pub fn process_id(&self) -> Option<u32> {
self.process_id
}
/// The Windows security identifier in its string form, e.g.
/// `S-1-5-21-3623811015-3361044348-30300820-1013` for a domain or local computer user or
/// "S-1-5-18` for the LOCAL_SYSTEM user.
pub fn windows_sid(&self) -> Option<&String> {
self.windows_sid.as_ref()
}
/// Same as [`ConnectionCredentials::windows_sid`], but consumes `self` and returns the SID
/// string.
pub fn into_windows_sid(self) -> Option<String> {
self.windows_sid
}
/// On Linux systems, the security label that would result from the SO_PEERSEC getsockopt call.
/// The array contains the non-zero bytes of the security label in an unspecified
/// ASCII-compatible encoding, followed by a single zero byte.
///
/// For example, the SELinux context `system_u:system_r:init_t:s0` (a string of length 27) would
/// be encoded as 28 bytes ending with `':', 's', '0', '\x00'`
///
/// On SELinux systems this is the SELinux context, as output by `ps -Z` or `ls -Z`. Typical
/// values might include `system_u:system_r:init_t:s0`,
/// `unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023`, or
/// `unconfined_u:unconfined_r:chrome_sandbox_t:s0-s0:c0.c1023`.
///
/// On Smack systems, this is the Smack label. Typical values might include `_`, `*`, `User`,
/// `System` or `System::Shared`.
///
/// On AppArmor systems, this is the AppArmor context, a composite string encoding the AppArmor
/// label (one or more profiles) and the enforcement mode. Typical values might include
/// `unconfined`, `/usr/bin/firefox (enforce)` or `user1 (complain)`.
pub fn linux_security_label(&self) -> Option<&Vec<u8>> {
self.linux_security_label.as_ref()
}
/// Same as [`ConnectionCredentials::linux_security_label`], but consumes `self` and returns
/// the security label bytes.
pub fn into_linux_security_label(self) -> Option<Vec<u8>> {
self.linux_security_label
}
/// Set the numeric Unix user ID, as defined by POSIX.
pub fn set_unix_user_id(mut self, unix_user_id: u32) -> Self {
self.unix_user_id = Some(unix_user_id);
self
}
/// Add a numeric Unix group ID.
///
/// See [`ConnectionCredentials::unix_group_ids`] for more information.
pub fn add_unix_group_id(mut self, unix_group_id: u32) -> Self {
self.unix_group_ids.get_or_insert_with(Vec::new).push(unix_group_id);
self
}
/// Set the numeric process ID, on platforms that have this concept.
///
/// See [`ConnectionCredentials::process_id`] for more information.
pub fn set_process_id(mut self, process_id: u32) -> Self {
self.process_id = Some(process_id);
self
}
/// Set the Windows security identifier in its string form.
pub fn set_windows_sid(mut self, windows_sid: String) -> Self {
self.windows_sid = Some(windows_sid);
self
}
/// Set the Linux security label.
///
/// See [`ConnectionCredentials::linux_security_label`] for more information.
pub fn set_linux_security_label(mut self, linux_security_label: Vec<u8>) -> Self {
self.linux_security_label = Some(linux_security_label);
self
}
}
#[rustfmt::skip]
macro_rules! gen_dbus_proxy {
($gen_async:literal, $gen_blocking:literal) => {
/// Proxy for the `org.freedesktop.DBus` interface.
#[proxy(
default_service = "org.freedesktop.DBus",
default_path = "/org/freedesktop/DBus",
interface = "org.freedesktop.DBus",
gen_async = $gen_async,
gen_blocking = $gen_blocking,
)]
trait DBus {