Struct winsafe::HFILEMAPVIEW [−][src]
#[repr(C)]pub struct HFILEMAPVIEW { /* fields omitted */ }
Expand description
Address of a
mapped view.
Originally just an LPVOID
.
Implementations
Creates a new handle instance by wrapping a pointer.
This method is common to all handle types.
Consumes the handle returning the underlying raw pointer.
This method is common to all handle types.
Tells if the handle is invalid (null).
This method is common to all handle types.
Consumes the handle into an option, which is None
if the handle
pointer is null.
This method is common to all handle types.
UnmapViewOfFile
method.
Returns a slice representing the mapped memory. You can modify the contents. You should call this method only if the file has write access.
Note: If the file is resized to a smaller size, the slice will still
map the bytes beyond the file. This may cause serious errors. So, if the
file is resized, re-generate the slice by calling as_slice
again.
Returns a slice representing the mapped memory.
Note: If the file is resized to a smaller size, the slice will still
map the bytes beyond the file. This may cause serious errors. So, if the
file is resized, re-generate the slice by calling as_slice
again.
Examples
Reading the contents of a file into a string:
use winsafe::{co, HFILE};
let hfile = HFILE::CreateFile(
"C:\\Temp\\test.txt",
co::GENERIC::READ,
co::FILE_SHARE::READ,
None,
co::DISPOSITION::OPEN_EXISTING,
co::FILE_ATTRIBUTE::NORMAL,
None,
)?;
let hmap = hfile.CreateFileMapping(
None,
co::PAGE::READONLY,
None,
None,
)?;
let view = hmap.MapViewOfFile(co::FILE_MAP::READ, 0, None)?;
let slice = view.as_slice(hfile.GetFileSizeEx()?);
let text = std::str::from_utf8(slice)?;
view.UnmapViewOfFile()?;
hmap.CloseHandle()?;
hfile.CloseHandle()?;
println!("{}", text);
Trait Implementations
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
This method tests for !=
.
Auto Trait Implementations
Blanket Implementations
Mutably borrows from an owned value. Read more