gio/auto/
dbus_interface.rs

1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir-files (https://github.com/gtk-rs/gir-files)
3// DO NOT EDIT
4
5use crate::{ffi, DBusInterfaceInfo, DBusObject};
6use glib::{prelude::*, translate::*};
7
8glib::wrapper! {
9    /// Base type for D-Bus interfaces.
10    ///
11    /// The `GDBusInterface` type is the base type for D-Bus interfaces both
12    /// on the service side (see [`DBusInterfaceSkeleton`][crate::DBusInterfaceSkeleton]) and client side
13    /// (see [`DBusProxy`][crate::DBusProxy]).
14    ///
15    /// # Implements
16    ///
17    /// [`DBusInterfaceExt`][trait@crate::prelude::DBusInterfaceExt]
18    #[doc(alias = "GDBusInterface")]
19    pub struct DBusInterface(Interface<ffi::GDBusInterface, ffi::GDBusInterfaceIface>);
20
21    match fn {
22        type_ => || ffi::g_dbus_interface_get_type(),
23    }
24}
25
26impl DBusInterface {
27    pub const NONE: Option<&'static DBusInterface> = None;
28}
29
30/// Trait containing all [`struct@DBusInterface`] methods.
31///
32/// # Implementors
33///
34/// [`DBusInterfaceSkeleton`][struct@crate::DBusInterfaceSkeleton], [`DBusInterface`][struct@crate::DBusInterface], [`DBusProxy`][struct@crate::DBusProxy]
35pub trait DBusInterfaceExt: IsA<DBusInterface> + 'static {
36    /// Gets the #GDBusObject that @self belongs to, if any.
37    ///
38    /// # Returns
39    ///
40    /// A #GDBusObject or [`None`]. The returned
41    /// reference should be freed with g_object_unref().
42    #[doc(alias = "g_dbus_interface_dup_object")]
43    #[doc(alias = "dup_object")]
44    fn get(&self) -> Option<DBusObject> {
45        unsafe {
46            from_glib_full(ffi::g_dbus_interface_dup_object(
47                self.as_ref().to_glib_none().0,
48            ))
49        }
50    }
51
52    /// Gets D-Bus introspection information for the D-Bus interface
53    /// implemented by @self.
54    ///
55    /// # Returns
56    ///
57    /// A #GDBusInterfaceInfo. Do not free.
58    #[doc(alias = "g_dbus_interface_get_info")]
59    #[doc(alias = "get_info")]
60    fn info(&self) -> DBusInterfaceInfo {
61        unsafe {
62            from_glib_none(ffi::g_dbus_interface_get_info(
63                self.as_ref().to_glib_none().0,
64            ))
65        }
66    }
67
68    /// Sets the #GDBusObject for @self to @object.
69    ///
70    /// Note that @self will hold a weak reference to @object.
71    /// ## `object`
72    /// A #GDBusObject or [`None`].
73    #[doc(alias = "g_dbus_interface_set_object")]
74    fn set_object(&self, object: Option<&impl IsA<DBusObject>>) {
75        unsafe {
76            ffi::g_dbus_interface_set_object(
77                self.as_ref().to_glib_none().0,
78                object.map(|p| p.as_ref()).to_glib_none().0,
79            );
80        }
81    }
82}
83
84impl<O: IsA<DBusInterface>> DBusInterfaceExt for O {}