pub struct FileVolatileSlice<'a> { /* private fields */ }
Expand description

An adapter structure to work around limitations of the vm-memory crate.

It solves the compilation failure by masking out the vm_memory::BitmapSlice generic type parameter of vm_memory::VolatileSlice.

Implementations§

Create a new instance of FileVolatileSlice from a raw pointer.

Safety

To use this safely, the caller must guarantee that the memory at addr is size bytes long and is available for the duration of the lifetime of the new FileVolatileSlice. The caller must also guarantee that all other users of the given chunk of memory are using volatile accesses.

Example
let mut buffer = [0u8; 1024];
let s = unsafe { FileVolatileSlice::from_raw_ptr(buffer.as_mut_ptr(), buffer.len()) };

{
    let o: u32 = s.load(0x10, Ordering::Acquire).unwrap();
    assert_eq!(o, 0);
    s.store(1u8, 0x10, Ordering::Release).unwrap();

    let s2 = s.as_volatile_slice();
    let s3 = FileVolatileSlice::from_volatile_slice(&s2);
    assert_eq!(s3.len(), 1024);
}

assert_eq!(buffer[0x10], 1);

Create a new instance of FileVolatileSlice from a mutable slice.

Safety

The caller must guarantee that all other users of the given chunk of memory are using volatile accesses.

Create a new FileVolatileSlice from vm_memory::VolatileSlice and strip off the vm_memory::BitmapSlice.

The caller needs to handle dirty page tracking for the data buffer.

Create a vm_memory::VolatileSlice from FileVolatileSlice without dirty page tracking.

Borrow as a FileVolatileSlice object to temporarily elide the lifetime parameter.

Safety

The FileVolatileSlice is borrowed without a lifetime parameter, so the caller must ensure that FileVolatileBuf doesn’t out-live the borrowed FileVolatileSlice object.

Return a pointer to the start of the slice.

Get the size of the slice.

Check if the slice is empty.

Return a subslice of this FileVolatileSlice starting at offset.

Trait Implementations§

Associated error codes
Writes a slice into the container at addr. Read more
Reads data from the container at addr into a slice. Read more
Writes the entire content of a slice into the container at addr. Read more
Reads data from the container at addr to fill an entire slice. Read more
Reads up to count bytes from an object and writes them into the container at addr. Read more
Reads exactly count bytes from an object and writes them into the container at addr. Read more
Reads up to count bytes from the container at addr and writes them it into an object. Read more
Reads exactly count bytes from the container at addr and writes them into an object. Read more
Atomically store a value at the specified address.
Atomically load a value from the specified address.
Writes an object into the container at addr. Read more
Reads an object from the container at addr. Read more
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

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
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.