pub fn query<T>(address: *const T) -> Result<Region>
Expand description
Queries the OS with an address, returning the region it resides within.
If the queried address does not reside within any mapped region, or if it’s
outside the process’ address space, the function will error with
Error::UnmappedRegion
.
§Parameters
- The enclosing region can be of multiple page sizes.
- The address is rounded down to the closest page boundary.
§Errors
- If an interaction with the underlying operating system fails, an error will be returned.
§Examples
use region::Protection;
let data = [0; 100];
let region = region::query(data.as_ptr())?;
assert_eq!(region.protection(), Protection::READ_WRITE);