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
30mod sealed {
31 pub trait Sealed {}
32 impl<T: super::IsA<super::DBusInterface>> Sealed for T {}
33}
34
35/// Trait containing all [`struct@DBusInterface`] methods.
36///
37/// # Implementors
38///
39/// [`DBusInterfaceSkeleton`][struct@crate::DBusInterfaceSkeleton], [`DBusInterface`][struct@crate::DBusInterface], [`DBusProxy`][struct@crate::DBusProxy]
40pub trait DBusInterfaceExt: IsA<DBusInterface> + sealed::Sealed + 'static {
41 /// Gets the #GDBusObject that @self belongs to, if any.
42 ///
43 /// # Returns
44 ///
45 /// A #GDBusObject or [`None`]. The returned
46 /// reference should be freed with g_object_unref().
47 #[doc(alias = "g_dbus_interface_dup_object")]
48 #[doc(alias = "dup_object")]
49 fn get(&self) -> Option<DBusObject> {
50 unsafe {
51 from_glib_full(ffi::g_dbus_interface_dup_object(
52 self.as_ref().to_glib_none().0,
53 ))
54 }
55 }
56
57 /// Gets D-Bus introspection information for the D-Bus interface
58 /// implemented by @self.
59 ///
60 /// # Returns
61 ///
62 /// A #GDBusInterfaceInfo. Do not free.
63 #[doc(alias = "g_dbus_interface_get_info")]
64 #[doc(alias = "get_info")]
65 fn info(&self) -> DBusInterfaceInfo {
66 unsafe {
67 from_glib_none(ffi::g_dbus_interface_get_info(
68 self.as_ref().to_glib_none().0,
69 ))
70 }
71 }
72
73 /// Sets the #GDBusObject for @self to @object.
74 ///
75 /// Note that @self will hold a weak reference to @object.
76 /// ## `object`
77 /// A #GDBusObject or [`None`].
78 #[doc(alias = "g_dbus_interface_set_object")]
79 fn set_object(&self, object: Option<&impl IsA<DBusObject>>) {
80 unsafe {
81 ffi::g_dbus_interface_set_object(
82 self.as_ref().to_glib_none().0,
83 object.map(|p| p.as_ref()).to_glib_none().0,
84 );
85 }
86 }
87}
88
89impl<O: IsA<DBusInterface>> DBusInterfaceExt for O {}