pub struct VolatileRef<'a, T, B = ()> { /* private fields */ }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§
Source§impl<'a, T> VolatileRef<'a, T, ()>where
    T: ByteValued,
 
impl<'a, T> VolatileRef<'a, T, ()>where
    T: ByteValued,
Sourcepub unsafe fn new(addr: *mut u8) -> Self
 
pub unsafe fn new(addr: *mut u8) -> Self
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.
Source§impl<'a, T, B> VolatileRef<'a, T, B>where
    T: ByteValued,
    B: BitmapSlice,
 
impl<'a, T, B> VolatileRef<'a, T, B>where
    T: ByteValued,
    B: BitmapSlice,
Sourcepub unsafe fn with_bitmap(addr: *mut u8, bitmap: B) -> Self
 
pub unsafe fn with_bitmap(addr: *mut u8, bitmap: B) -> Self
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.
Sourcepub fn as_ptr(&self) -> *mut u8
 
pub fn as_ptr(&self) -> *mut u8
Returns a pointer to the underlying memory. Mutable accesses performed using the resulting pointer are not automatically accounted for by the dirty bitmap tracking functionality.
Sourcepub fn len(&self) -> usize
 
pub fn len(&self) -> usize
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);Sourcepub fn to_slice(&self) -> VolatileSlice<'a, B>
 
pub fn to_slice(&self) -> VolatileSlice<'a, B>
Converts this to a VolatileSlice with the same size and
address.
Trait Implementations§
Source§impl<'a, T: Clone, B: Clone> Clone for VolatileRef<'a, T, B>
 
impl<'a, T: Clone, B: Clone> Clone for VolatileRef<'a, T, B>
Source§fn clone(&self) -> VolatileRef<'a, T, B>
 
fn clone(&self) -> VolatileRef<'a, T, B>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
 
fn clone_from(&mut self, source: &Self)
source. Read more