How to make sense of dbus arguments

I want to use dbus to list all removable devices. The UDisks2 specs defines GetBlockDevices method on org.freedesktop.UDisks2.Manager interface. It's defined as follows:

GetBlockDevices (IN  a{sv} options,
                 OUT ao    block_objects);

The "in" parameter a{sv}, is (if I am not mistaken) a HashMap.

http://storaged.org/doc/udisks2-api/latest/gdbus-org.freedesktop.UDisks2.Manager.html#gdbus-method-org-freedesktop-UDisks2-Manager.GetBlockDevices

However the Key and the Value type does not make any sense to me. I set up my dbus cunnection as follows:

fn main() -> Result<(), Box<dyn std::error::Error>> {
    use dbus::blocking::{Connection, Proxy};

    let conn = Connection::new_system()?;
    let proxy = Proxy::new(
        "org.freedesktop.UDisks2",
        "/org/freedesktop/UDisks2/Manager",
        std::time::Duration::from_millis(5000),
        &conn,
    );
    let devices = proxy.method_call(
        "org.freedesktop.UDisks2.Manager",
        "GetBlockDevices",
        // ?? ("in" arg goes here)
    )?;
    dbg!(devices);
    Ok(())
}

upon further inspection I deduced that the type should be std::collections::HashMap::<&str, dbus::arg::Variant<Box<dyn dbus::arg::RefArg>>>()

However it looks like I need to put it inside a tuple (No idea how or why), looking at the generated code: https://gist.github.com/rust-play/64f4f4c6a682f6828bbeb11a490d5255#file-playground-rs-L239

Any pointers?

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.