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

Retrieve the signature of a property’s type from XML.

§Examples

use std::fs::File;
use std::io::{Seek, SeekFrom, Write};
use tempfile::tempfile;
use zvariant::Type;
use zbus_lockstep::get_property_type;
     
#[derive(Debug, PartialEq, Type)]
struct InUse(bool);
     
let xml = String::from(r#"
<node>
<interface name="org.freedesktop.GeoClue2.Manager">
  <property type="b" name="InUse" access="read"/>
</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.freedesktop.GeoClue2.Manager";
let property_name = "InUse";

let signature = get_property_type(xml_file, interface_name, property_name).unwrap();
assert_eq!(signature, InUse::signature());