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 /// This can return [`None`] if no #GDBusInterfaceInfo was provided during
56 /// construction of @self and is also not made available otherwise.
57 /// For example, #GDBusProxy implements #GDBusInterface but allows for a [`None`]
58 /// #GDBusInterfaceInfo.
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) -> Option<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 {}