windows_safe_handle
Generate smart pointers for windows raw handles with ergonomic APIs.
safe_handle!
This crate doesn't offer pre-defined smart pointers. Instead, it provides a single safe_handle! macro for generation:
Simple Smart Pointer, calling an unsafe Function on Drop
use safe_handle;
use ;
safe_handle!;
If you do not need to export the Handle type, simply omit the pub keyword.
Smart Pointer with additional Drop logic
You can use a closure-based syntax:
use safe_handle;
use ;
safe_handle!;
Note that in this case you have to explicitly use unsafe block.
Versions
v0.1.*: Compatible withwindowsv0.48.0.v0.2.*: Compatible withwindowsv0.58.0.
Example
Refer to tests/bcrypt_hash.rs to see how to safely wrap Windows Cryptography Next Generation (CNG) APIs for calculating MD5 hashes.