Open
Description
Suggestion
A COM interface whose methods are SAL annotated is usually simplified. However, the generated _Impl
trait is less simplified.
For example, consider the following interface:
DEFINE_INTERFACE(ITestInterface, "7E17AD3C-47AF-4A71-85BD-1122EAB7E794") : public IUnknown
{
STDMETHOD_(HRESULT, EncryptBuffer)
(__in_bcount(cbSize) BYTE * pBuffer, _In_ size_t cbSize, _Out_ IBuffer * *ppvObj) = 0;
};
The generated ITestInterface
looks like that:
impl ITestInterface {
pub unsafe fn EncryptBuffer(
&self,
pbuffer: &mut [u8],
) -> windows_core::Result<IBuffer> {
// ...
}
}
pBuffer
and cbSize
were nicely merged into a mutable slice thanks to the SAL annotations. However, when implementing this interface we need to implement the following trait:
pub trait ITestInterface_Impl: Sized {
fn EncryptBuffer(
&self,
pbuffer: *mut u8,
cbsize: usize,
) -> windows_core::Result<IBuffer>;
}
The return value for the _Impl
trait method was simplified, but not the slice param. If it was simplified as well, it would allow us to implement the interface without using unsafe code