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