gio/dbus_node_info.rs
1// Take a look at the license at the top of the repository in the LICENSE file.
2
3use std::ffi::CStr;
4
5use crate::{DBusInterfaceInfo, DBusNodeInfo};
6
7impl DBusNodeInfo {
8 pub fn path(&self) -> Option<&str> {
9 unsafe {
10 let c_obj = self.as_ptr();
11 let path = (*c_obj).path;
12 if path.is_null() {
13 return None;
14 }
15 let c_str = CStr::from_ptr(path);
16 Some(c_str.to_str().unwrap())
17 }
18 }
19
20 pub fn interfaces(&self) -> &[DBusInterfaceInfo] {
21 unsafe {
22 let c_obj = self.as_ptr();
23 let c_ii = (*c_obj).interfaces;
24 if c_ii.is_null() {
25 return &[];
26 }
27
28 glib::collections::PtrSlice::from_glib_borrow(c_ii)
29 }
30 }
31
32 pub fn nodes(&self) -> &[DBusNodeInfo] {
33 unsafe {
34 let c_obj = self.as_ptr();
35 let c_ni = (*c_obj).nodes;
36 if c_ni.is_null() {
37 return &[];
38 }
39 glib::collections::PtrSlice::from_glib_borrow(c_ni)
40 }
41 }
42}