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

Retrieve the signature of a method’s return type from 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 std::fs::File;
use std::io::{Seek, SeekFrom, Write};
use tempfile::tempfile;
use zvariant::Type;
use zbus_lockstep::get_method_return_type;
     
#[derive(Debug, PartialEq, Type)]
#[repr(u32)]
enum Role {
    Invalid,
    TitleBar,
    MenuBar,
    ScrollBar,
}

let xml = String::from(r#"
<node>
<interface name="org.a11y.atspi.Accessible">
   <method name="GetRole">
      <arg name="role" type="u" direction="out"/>
  </method>
</interface>
</node>
"#);

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

let interface_name = "org.a11y.atspi.Accessible";
let member_name = "GetRole";
     
let signature = get_method_return_type(xml_file, interface_name, member_name, None).unwrap();
assert_eq!(signature, Role::signature());