-
Notifications
You must be signed in to change notification settings - Fork 528
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
implement
macro not implementing the Interface
trait?
#2882
Comments
Interface
trait?implement
macro not implmenting the Interface
trait?
implement
macro not implmenting the Interface
trait?implement
macro not implementing the Interface
trait?
Alternatively, should I implement |
I got this working by using let callback_object: ILocationEvents = LocationCallbacks{}.into();
unsafe{
location_provider.RegisterForReport(
&callback_object,
&ILatLongReport::IID as *const _,
100,
)?
}; |
Awesome, thanks a lot :) But how can we document this so that others could benefit from this? |
That's the key here. It was indeed visible in the example you're linking (and which I had a look at), but it was easy to miss. |
That's also irritating that documentation on COM api is ridiculously hard to find as Google mostly ignores the "COM" keyword (or rather, it matches most of the documentation that is hosted on a .com TLD, and is thus effectively a useless keyword) |
Sure, that sounds great thanks. |
Summary
I'd like to use the
RegisterForReport
COM function, that requires to create a class that inheritsILocationEvents
.I could implement a suitable struct using
#[implement(ILocationEvents)]
(and aimpl ILocationEvents_Impl for ...
block), but the compiler refuses to use the Rust binding to this COM function because my custom Struct does not implementInterface
. I pasted the actual error messages in the reproducer code below.I am not sure what is wrong here.
But the examples I could read here and there did not specify anything about explicily implementing this
Interface
.Iterface
. Given the doc of this trait, I'm not supposed to implement it myself. I could not successfully tell the#[implement]
macro to implement it, as my attempts such as#[implement(ILocationEvents, Interface)]
fail to compile.#[implement(ILocationEvents)]
know it is supposed to implementInterface
as well? If so, is something missing from windows-rs/winmd side?RegisterForReport
, I tried passingmy_struct.cast::<ILocationEvents>()
, which compiles but (not so surprisingly) crashes at runtime.Thanks a lot
Crate manifest
Crate code
The text was updated successfully, but these errors were encountered: