Function sparse_mmap::try_read_volatile

source ·
pub unsafe fn try_read_volatile<T: FromBytes>(
    src: *const T,
) -> Result<T, MemoryError>
Expand description

Reads the value at src treating the pointer as a volatile access.

Returns Ok(T) if the read was successful, or Err(MemoryError) if the read was unsuccessful.

Panics if the size is not 1, 2, 4, or 8 bytes.

§Safety

This routine is safe to use if the memory pointed to by src is being concurrently mutated.

WARNING: This routine should only be used when you know that src is valid, reserved addresses but you do not know if they are mapped with the appropriate protection. For example, this routine is useful if src is a sparse mapping where some pages are mapped with PAGE_NOACCESS/PROT_NONE, and some are mapped with PAGE_READWRITE/PROT_WRITE.