gio/auto/
dbus_node_info.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};
6use glib::translate::*;
7
8glib::wrapper! {
9    /// Information about nodes in a remote object hierarchy.
10    #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
11    pub struct DBusNodeInfo(Shared<ffi::GDBusNodeInfo>);
12
13    match fn {
14        ref => |ptr| ffi::g_dbus_node_info_ref(ptr),
15        unref => |ptr| ffi::g_dbus_node_info_unref(ptr),
16        type_ => || ffi::g_dbus_node_info_get_type(),
17    }
18}
19
20impl DBusNodeInfo {
21    /// Parses @xml_data and returns a #GDBusNodeInfo representing the data.
22    ///
23    /// The introspection XML must contain exactly one top-level
24    /// `<node>` element.
25    ///
26    /// Note that this routine is using a
27    /// [GMarkup](../glib/markup.html)-based
28    /// parser that only accepts a subset of valid XML documents.
29    /// ## `xml_data`
30    /// Valid D-Bus introspection XML.
31    ///
32    /// # Returns
33    ///
34    /// A #GDBusNodeInfo structure or [`None`] if @error is set. Free
35    /// with g_dbus_node_info_unref().
36    #[doc(alias = "g_dbus_node_info_new_for_xml")]
37    #[doc(alias = "new_for_xml")]
38    pub fn for_xml(xml_data: &str) -> Result<DBusNodeInfo, glib::Error> {
39        unsafe {
40            let mut error = std::ptr::null_mut();
41            let ret = ffi::g_dbus_node_info_new_for_xml(xml_data.to_glib_none().0, &mut error);
42            if error.is_null() {
43                Ok(from_glib_full(ret))
44            } else {
45                Err(from_glib_full(error))
46            }
47        }
48    }
49
50    //#[doc(alias = "g_dbus_node_info_generate_xml")]
51    //pub fn generate_xml(&self, indent: u32, string_builder: /*Ignored*/&mut glib::String) {
52    //    unsafe { TODO: call ffi:g_dbus_node_info_generate_xml() }
53    //}
54
55    /// Looks up information about an interface.
56    ///
57    /// The cost of this function is O(n) in number of interfaces.
58    /// ## `name`
59    /// A D-Bus interface name.
60    ///
61    /// # Returns
62    ///
63    /// A #GDBusInterfaceInfo or [`None`] if not found. Do not free, it is owned by @self.
64    #[doc(alias = "g_dbus_node_info_lookup_interface")]
65    pub fn lookup_interface(&self, name: &str) -> Option<DBusInterfaceInfo> {
66        unsafe {
67            from_glib_none(ffi::g_dbus_node_info_lookup_interface(
68                self.to_glib_none().0,
69                name.to_glib_none().0,
70            ))
71        }
72    }
73}