-
Notifications
You must be signed in to change notification settings - Fork 113
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
Functions in windows::Win32::Graphics::Gdi
should return Result
#1758
Comments
BTW: On the page for |
The Win32 metadata project is aimed at modeling all the APIs in a language-neutral manner. Metadata currently represents [DllImport("GDI32.dll", ExactSpelling = true, PreserveSig = false)]
[Documentation("https://learn.microsoft.com/windows/win32/api/wingdi/nf-wingdi-createsolidbrush")]
...
public static extern HBRUSH CreateSolidBrush([In] COLORREF color); And Rust (windows) generates: pub unsafe fn CreateSolidBrush<P0>(color: P0) -> HBRUSH
where
P0: IntoParam<COLORREF> @kennykerr With |
Upon further thought, it's not clear how Rust would know when to apply such a transformation. It can't assume all functions returning |
The situation cannot be improved here. None of the functions listed set the calling thread's last error code. The metadata already does the right thing by not applying the |
What about providing EDIT: Or rather EDIT: This impl is an example of other code that chooses something fitting: impl std::convert::From<std::string::FromUtf16Error> for Error {
fn from(_: std::string::FromUtf16Error) -> Self {
Self { code: HRESULT::from_win32(crate::imp::ERROR_NO_UNICODE_TRANSLATION), info: None }
}
} |
What should the win32metadata team change to make that happen? |
I don't know your system and what it allows you to implement. I also don't have a clear understanding of the border between this repo and the |
In
windows::Win32::Graphics::Gdi
, there are many functions likeCreateSolidBrush()
,CreateBitmap()
,CreateBitmapIndirect()
,CreateEllipticRgn()
etc. that return handles, although the docs at learn.microsoft.com say, they can fail. So, they should returnResult
s like many other fallible functions in thewindows
crate already do.The text was updated successfully, but these errors were encountered: