{"action":"created","issue":{"url":"https://api.github.com/repos/diwic/dbus-rs/issues/64","repository_url":"https://api.github.com/repos/diwic/dbus-rs","labels_url":"https://api.github.com/repos/diwic/dbus-rs/issues/64/labels{/name}","comments_url":"https://api.github.com/repos/diwic/dbus-rs/issues/64/comments","events_url":"https://api.github.com/repos/diwic/dbus-rs/issues/64/events","html_url":"https://github.com/diwic/dbus-rs/issues/64","id":198457048,"number":64,"title":"The trait bound `dbus::arg::Get` is not satisfied","user":{"login":"josephroberts","id":1107385,"avatar_url":"https://avatars.githubusercontent.com/u/1107385?v=3","gravatar_id":"","url":"https://api.github.com/users/josephroberts","html_url":"https://github.com/josephroberts","followers_url":"https://api.github.com/users/josephroberts/followers","following_url":"https://api.github.com/users/josephroberts/following{/other_user}","gists_url":"https://api.github.com/users/josephroberts/gists{/gist_id}","starred_url":"https://api.github.com/users/josephroberts/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/josephroberts/subscriptions","organizations_url":"https://api.github.com/users/josephroberts/orgs","repos_url":"https://api.github.com/users/josephroberts/repos","events_url":"https://api.github.com/users/josephroberts/events{/privacy}","received_events_url":"https://api.github.com/users/josephroberts/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2017-01-03T11:37:22Z","updated_at":"2017-01-05T04:29:54Z","closed_at":null,"body":"I am trying to use this library to get connection info from NetworkManager using the `GetSettings` method. I used D-Feet to try out the function which has a signature of `GetSettings() -> (Dict of {String, Dict of {String, Variant} } settings)`, the data returned by D-Feet is below: \r\n\r\n    {'802-11-wireless': {'mac-address': [228, 179, 24, 77, 64, 139],\r\n                         'mac-address-blacklist': [],\r\n                         'mode': 'infrastructure',\r\n                         'security': '802-11-wireless-security',\r\n                         'seen-bssids': ['02:1D:AA:80:1B:DA', '02:1D:AA:80:1D:12'],\r\n                         'ssid': [80,\r\n                                  108,\r\n                                  111,\r\n                                  117,\r\n                                  103,\r\n                                  104,\r\n                                  32,\r\n                                  87,\r\n                                  97,\r\n                                  121,\r\n                                  32,\r\n                                  67,\r\n                                  97,\r\n                                  102,\r\n                                  101]},\r\n     '802-11-wireless-security': {'auth-alg': 'open',\r\n                                  'group': [],\r\n                                  'key-mgmt': 'wpa-psk',\r\n                                  'pairwise': [],\r\n                                  'proto': []},\r\n     'connection': {'id': 'Plough Way Cafe',\r\n                    'permissions': [],\r\n                    'secondaries': [],\r\n                    'timestamp': 1479304123,\r\n                    'type': '802-11-wireless',\r\n                    'uuid': 'ff9b7028-0911-491a-bfe8-53cba76069da'},\r\n     'ipv4': {'address-data': [],\r\n              'addresses': [],\r\n              'dns': [],\r\n              'dns-search': [],\r\n              'method': 'auto',\r\n              'route-data': [],\r\n              'routes': []},\r\n     'ipv6': {'address-data': [],\r\n              'addresses': [],\r\n              'dns': [],\r\n              'dns-search': [],\r\n              'method': 'auto',\r\n              'route-data': [],\r\n              'routes': []}}\r\n\r\nand my code:\r\n\r\n    extern crate dbus;\r\n\r\n    fn main() {\r\n        let message = dbus::Message::new_method_call(\"org.freedesktop.NetworkManager\",\r\n                                                     \"/org/freedesktop/NetworkManager/Settings/0\",\r\n                                                     \"org.freedesktop.NetworkManager.Settings.\\\r\n                                                      Connection\",\r\n                                                     \"GetSettings\")\r\n            .unwrap();\r\n\r\n        let response = dbus::Connection::get_private(dbus::BusType::System)\r\n            .unwrap()\r\n            .send_with_reply_and_block(message, 2000)\r\n            .unwrap();\r\n\r\n        println!(\"{:?}\", response);\r\n\r\n        let test: dbus::arg::Dict<&str, dbus::arg::Dict<&str, dbus::arg::Variant<()>, _>, _> =\r\n            response.get1().unwrap();\r\n\r\n        println!(\"{:?}\", test);\r\n    }\r\n\r\nwhich results in this error:\r\n\r\n<!-- language: none -->\r\n\r\n    error[E0277]: the trait bound `(): dbus::arg::Get<'_>` is not satisfied\r\n      --> src/main.rs:20:18\r\n       |\r\n    20 |         response.get1().unwrap();\r\n       |                  ^^^^ the trait `dbus::arg::Get<'_>` is not implemented for `()`\r\n       |\r\n       = note: required because of the requirements on the impl of `dbus::arg::Get<'_>` for `dbus::arg::Variant<()>`\r\n       = note: required because of the requirements on the impl of `dbus::arg::Get<'_>` for `dbus::arg::Dict<'_, &str, dbus::arg::Variant<()>, dbus::arg::Iter<'_>>`\r\n       = note: required because of the requirements on the impl of `dbus::arg::Get<'_>` for `dbus::arg::Dict<'_, &str, dbus::arg::Dict<'_, &str, dbus::arg::Variant<()>, dbus::arg::Iter<'_>>,     dbus::arg::Iter<'_>>`\r\n    \r\n\r\nHow can I get the connection info?\r\n\r\nI thought the whole point of `Variant` is that it can hold different types of data? What am I doing wrong?\r\n\r\nIf I substitute the `Variant` type `()` with `&str` it prints out `Dict(Iter(\"Unknown?!\", \"Unknown?!\", \"Unknown?!\", \"Unknown?!\", \"Unknown?!\"), PhantomData)`. What is the `Unknown?!` value?\r\n\r\nThe [API for `Dict`](https://docs.rs/dbus/0.4.1/dbus/arg/struct.Dict.html) also states\r\n\r\n> Creates a new `Dict` from an iterator. The iterator is consumed when appended.\r\n\r\nHow/should I use this instead?\r\n\r\n**UPDATE**\r\n\r\nI have managed to make some progress, perhaps naively?\r\n\r\nMy code now looks like this:\r\n\r\n    extern crate dbus;\r\n    extern crate network_manager;\r\n\r\n    #[derive(Default, Debug)]\r\n    struct Connection {\r\n        path: String,\r\n        id: String,\r\n        uuid: String,\r\n        ssid: String,\r\n        interface: String,\r\n        security: String,\r\n        psk: String, // Only used when creating a new connection\r\n    }\r\n\r\n    fn main() {\r\n        let connection = Connection {\r\n            path: \"/org/freedesktop/NetworkManager/Settings/0\".to_string(),\r\n            ..Default::default()\r\n        };\r\n\r\n        let message = dbus::Message::new_method_call(\"org.freedesktop.NetworkManager\",\r\n                                                     connection.path.clone(),\r\n                                                     \"org.freedesktop.NetworkManager.Settings.\\\r\n                                                      Connection\",\r\n                                                     \"GetSettings\")\r\n            .unwrap();\r\n\r\n        let response = dbus::Connection::get_private(dbus::BusType::System)\r\n            .unwrap()\r\n            .send_with_reply_and_block(message, 2000)\r\n            .unwrap();\r\n\r\n        let mut outer_array_iter = response.iter_init().recurse(97).unwrap();\r\n        loop {\r\n            let mut outer_dict_iter = outer_array_iter.recurse(101).unwrap();\r\n            outer_dict_iter.next();\r\n\r\n            let mut inner_array_iter = outer_dict_iter.recurse(97).unwrap();\r\n            loop {\r\n                let mut inner_dict_iter = inner_array_iter.recurse(101).unwrap();\r\n\r\n                let key = inner_dict_iter.read::<&str>().unwrap();\r\n                match key {\r\n                    \"id\" => {\r\n                        let val: dbus::arg::Variant<&str> = inner_dict_iter.read().unwrap();\r\n                        println!(\"id {:?}\", val);\r\n                    }\r\n                    \"uuid\" => {\r\n                        let val: dbus::arg::Variant<&str> = inner_dict_iter.read().unwrap();\r\n                        println!(\"uuid {:?}\", val);\r\n                    }\r\n                    \"ssid\" => {\r\n                        let val: dbus::arg::Variant<dbus::arg::Array<i32, _>> = inner_dict_iter.read()\r\n                            .unwrap();\r\n                        println!(\"ssid {:?}\", val);\r\n                    }\r\n                    \"type\" => {\r\n                        let val: dbus::arg::Variant<&str> = inner_dict_iter.read().unwrap();\r\n                        println!(\"interface {:?}\", val);\r\n                    }\r\n                    \"security\" => {\r\n                        let val: dbus::arg::Variant<&str> = inner_dict_iter.read().unwrap();\r\n                        println!(\"security {:?}\", val);\r\n                    }\r\n                    _ => (),\r\n                }\r\n\r\n                if !(inner_array_iter.next()) {\r\n                    break;\r\n                }\r\n            }\r\n\r\n            if !(outer_array_iter.next()) {\r\n                break;\r\n            }\r\n        }\r\n\r\n        println!(\"{:?}\", connection);\r\n    }\r\n\r\nthis prints out:\r\n\r\n    id Variant(\"Plough Way Cafe\")\r\n    uuid Variant(\"e078808e-626f-4be9-bbb4-5e48b1d626de\")\r\n    interface Variant(\"802-11-wireless\")\r\n    ssid Variant(Array(Iter(\"u8\", \"u8\", \"u8\", \"u8\", \"u8\", \"u8\", \"u8\", \"u8\"), PhantomData))\r\n    security Variant(\"802-11-wireless-security\")\r\n    Connection { path: \"/org/freedesktop/NetworkManager/Settings/0\", id: \"\", uuid: \"\", ssid: \"\", interface: \"\", security: \"\", psk: \"\" }\r\n\r\nHow can I get the data out of `Variant` and into my `connection` struct?\r\n\r\nIs there a better way to use iterators as this feels v.fragile?\r\n\r\nThanks"},"comment":{"url":"https://api.github.com/repos/diwic/dbus-rs/issues/comments/270561593","html_url":"https://github.com/diwic/dbus-rs/issues/64#issuecomment-270561593","issue_url":"https://api.github.com/repos/diwic/dbus-rs/issues/64","id":270561593,"user":{"login":"diwic","id":9721510,"avatar_url":"https://avatars.githubusercontent.com/u/9721510?v=3","gravatar_id":"","url":"https://api.github.com/users/diwic","html_url":"https://github.com/diwic","followers_url":"https://api.github.com/users/diwic/followers","following_url":"https://api.github.com/users/diwic/following{/other_user}","gists_url":"https://api.github.com/users/diwic/gists{/gist_id}","starred_url":"https://api.github.com/users/diwic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/diwic/subscriptions","organizations_url":"https://api.github.com/users/diwic/orgs","repos_url":"https://api.github.com/users/diwic/repos","events_url":"https://api.github.com/users/diwic/events{/privacy}","received_events_url":"https://api.github.com/users/diwic/received_events","type":"User","site_admin":false},"created_at":"2017-01-05T04:29:54Z","updated_at":"2017-01-05T04:29:54Z","body":" > I thought the whole point of Variant is that it can hold different types of data?\r\n\r\nThe Variant story is a bit tricky since Rust is so strongly typed. I'm working on using trait objects for better dynamics but I'm not sure I have arrived at the best design yet.\r\n\r\n > it prints out Dict(Iter(\"Unknown?!\", \"Unknown?!\", \"Unknown?!\", \"Unknown?!\", \"Unknown?!\"), PhantomData). What is the Unknown?! value?\r\n\r\nThis is fixed in git master. It now prints `Dict(Iter(DictEntry, DictEntry, DictEntry, DictEntry), PhantomData)` instead (as many as there are dict entries). "}}
{"actor":{"display_login":"diwic"}}