contextfree / winrt-rust

Use and (eventually) make Windows Runtime APIs with Rust
Apache License 2.0
142 stars 10 forks source link

How to create API parameter `foundation::collections::IIterable<HString>` ? #85

Closed kaz399 closed 4 years ago

kaz399 commented 4 years ago

I want to use devices::DeviceInformation::create_watcher_with_kind_aqs_filter_and_additional_properties().

I read sample code, but I can't understand how to create the second parameter additionalProperties: &foundation::collections::IIterable<HString>.

What do I do? Please someone tell me how to get it.

pub fn create_watcher_with_kind_aqs_filter_and_additional_properties(aqsFilter: &HStringArg, additionalProperties: &foundation::collections::IIterable<HString>, kind: DeviceInformationKind) -> Result<Option<ComPtr<DeviceWatcher>>>
Boddlnagg commented 4 years ago

I'm afraid that feature is currently missing ... only the other way around is implemented (IIterable to Rust iterator). We'd probably need something like winrt::array_view in C++/WinRT (see https://docs.microsoft.com/en-us/windows/uwp/cpp-and-winrt-apis/std-cpp-data-types), or directly wrap a dyn Iterator<...> or dyn IntoIterator<...> in a WinRT structure that implements IIterable. Needs quite a bit of thought to provide a nice API, though ...

kaz399 commented 4 years ago

OK, I understand the current state. Thank you!