pub struct FileHandle {
pub handle: HANDLE,
}Expand description
§Windows File Handle Wrapper
Introduces a Rust-friendly wrapper around the native Windows HANDLE object, FileHandle.
FileHandle provides safe creation and automatic cleanup of Windows file handles, leveraging Rust’s ownership model.
FileHandle struct that wraps a native Windows HANDLE object
Fields§
§handle: HANDLEImplementations§
Source§impl FileHandle
impl FileHandle
Sourcepub unsafe fn new(
file_name: &str,
access_mode: AccessMode,
share_mode: ShareMode,
) -> Result<Self>
pub unsafe fn new( file_name: &str, access_mode: AccessMode, share_mode: ShareMode, ) -> Result<Self>
Creates a new FileHandle by opening an existing file with the given access and shared mode.
This function is marked unsafe because it creates a raw pointer to the filename and try to create
a Windows HANDLE object without checking if you have sufficient permissions.
§Safety
Ensure that the file specified by file_name is valid and the calling process has
sufficient permissions to perform the specified access_mode and share_mode operations.
§Parameters
file_name: The name of the file.access_mode: The access mode to be used for the file.share_mode: The share mode to be used for the file
§Errors
This function will return an error if the file_name is invalid or if the file cannot
be opened with the specified access_mode and share_mode.
Trait Implementations§
Source§impl Default for FileHandle
Returns a FileHandle with an INVALID_HANDLE_VALUE.
impl Default for FileHandle
Returns a FileHandle with an INVALID_HANDLE_VALUE.