Use official windows-sys crate for WinAPI instead of deprecated winapi crate#457
Merged
0xpr03 merged 1 commit intonotify-rs:mainfrom Dec 5, 2022
Merged
Use official windows-sys crate for WinAPI instead of deprecated winapi crate#4570xpr03 merged 1 commit intonotify-rs:mainfrom
0xpr03 merged 1 commit intonotify-rs:mainfrom
Conversation
Contributor
Author
|
Btw, windows-sys MSRV is 1.49 |
0xpr03
reviewed
Dec 5, 2022
| CloseHandle, ERROR_OPERATION_ABORTED, HANDLE, INVALID_HANDLE_VALUE, WAIT_OBJECT_0, | ||
| }; | ||
| use windows_sys::Win32::Storage::FileSystem::{ | ||
| CreateFileW, ReadDirectoryChangesW, FILE_ACTION_ADDED, FILE_ACTION_MODIFIED, |
Member
There was a problem hiding this comment.
I think it's better to just do ::* for this case.
Contributor
Author
There was a problem hiding this comment.
windows_sys::Win32::Storage::FileSystem is pretty big, so ::* may lead to great scope pollution…
I am thinking about use windows_sys::Win32::Storage::FileSystem as fileapi, so it will have a short name, like in winapi.
There was a problem hiding this comment.
I sometimes use a custom prelude module for that
mod win {
pub use windows_sys::Win32::Foundation::*;
pub use windows_sys::Win32::Storage::*;
pub use windows_sys::Win32::Threading::*;
pub use windows_sys::Win32::WindowsProgramming::*;
pub use windows_sys::Win32::IO::*;
}
// ...
handle = win::CreateFileW(
encoded_path.as_ptr(),
win::FILE_LIST_DIRECTORY,
win::FILE_SHARE_READ | win::FILE_SHARE_DELETE | win::FILE_SHARE_WRITE,
ptr::null_mut(),
win::OPEN_EXISTING,
win::FILE_FLAG_BACKUP_SEMANTICS | win::FILE_FLAG_OVERLAPPED,
0,
);
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
winapicrate is kinda deprecated.windowsandwindows-syscan be used instead. They are maintained directly by Microsoft and are actively developed.windows-sysis a trimmed down version ofwindows. It offers better compilation time, and it is released once per 6 months.I removed winapi dependency and replaced in with windows-sys.