pub fn get_signal_body_type<'a>(
    xml: impl Read,
    interface_name: &str,
    member_name: &str,
    arg: Option<&str>
) -> Result<Signature<'a>, Box<dyn Error>>
Expand description

Retrieve a signal’s body type signature from DBus XML.

If you provide an argument name, then the signature of that argument is returned. If you do not provide an argument name, then the signature of all arguments is returned.

§Examples

use zvariant::{Signature, Type, OwnedObjectPath};
use zbus_lockstep::get_signal_body_type;

let xml = r#"<?xml version="1.0" encoding="UTF-8"?>
<node xmlns:doc="http://www.freedesktop.org/dbus/1.0/doc.dtd">
<interface name="org.freedesktop.bolt1.Manager">
  <signal name="DeviceAdded">
   <arg name="device" type="o"/>
 </signal>
</interface>
</node>
"#;

let mut xml_file: File = tempfile().unwrap();   
xml_file.write_all(xml.as_bytes()).unwrap();
xml_file.seek(SeekFrom::Start(0)).unwrap();

#[derive(Debug, PartialEq, Type)]
struct DeviceEvent {
   device: OwnedObjectPath,
}

let interface_name = "org.freedesktop.bolt1.Manager";
let member_name = "DeviceAdded";

let signature = get_signal_body_type(xml_file, interface_name, member_name, None).unwrap();

// Single `DBus` type codes, here 'o', are returned as a single character.
// Also, signal body types (often) omit the struct or tuple type parentheses.

assert_eq!(&signature, &DeviceEvent::signature());