Struct vm_memory::volatile_memory::VolatileRef[][src]

pub struct VolatileRef<'a, T, B = ()> { /* fields omitted */ }
Expand description

A memory location that supports volatile access to an instance of T.

Examples

let mut v = 5u32;
let v_ref = unsafe { VolatileRef::new(&mut v as *mut u32 as *mut u8) };

assert_eq!(v, 5);
assert_eq!(v_ref.load(), 5);
v_ref.store(500);
assert_eq!(v, 500);

Implementations

Creates a VolatileRef to an instance of T.

Safety

To use this safely, the caller must guarantee that the memory at addr is big enough for a T and is available for the duration of the lifetime of the new VolatileRef. The caller must also guarantee that all other users of the given chunk of memory are using volatile accesses.

Creates a VolatileRef to an instance of T, using the provided bitmap object for dirty page tracking.

Safety

To use this safely, the caller must guarantee that the memory at addr is big enough for a T and is available for the duration of the lifetime of the new VolatileRef. The caller must also guarantee that all other users of the given chunk of memory are using volatile accesses.

Returns a pointer to the underlying memory.

Gets the size of the referenced type T.

Examples

let v_ref = unsafe { VolatileRef::<u32>::new(0 as *mut _) };
assert_eq!(v_ref.len(), size_of::<u32>() as usize);

Borrows the inner BitmapSlice.

Does a volatile write of the value v to the address of this ref.

Does a volatile read of the value at the address of this ref.

Converts this to a VolatileSlice with the same size and address.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.