pub struct SliceGuestMemory { /* private fields */ }Expand description
In-process GuestMemory implementation backed by a single contiguous
Vec<u8> keyed at a fixed base guest address.
Useful for unit tests that need a real GuestMemory without standing up
the HVF backend. Production hypervisor backends provide their own
implementation that routes to mmap-backed regions.
Implementations§
Source§impl SliceGuestMemory
impl SliceGuestMemory
Sourcepub fn new(base: GuestAddress, size: usize) -> Self
pub fn new(base: GuestAddress, size: usize) -> Self
Build a [base, base + size) region zero-filled at construction.
Sourcepub fn from_bytes(base: GuestAddress, bytes: Vec<u8>) -> Self
pub fn from_bytes(base: GuestAddress, bytes: Vec<u8>) -> Self
Build a region pre-populated with bytes starting at base.
Sourcepub fn base(&self) -> GuestAddress
pub fn base(&self) -> GuestAddress
Inclusive base address.
Trait Implementations§
Source§impl Debug for SliceGuestMemory
impl Debug for SliceGuestMemory
Source§impl GuestMemory for SliceGuestMemory
impl GuestMemory for SliceGuestMemory
Source§fn read_u16_le(&self, addr: GuestAddress) -> Result<u16>
fn read_u16_le(&self, addr: GuestAddress) -> Result<u16>
Source§fn read_u32_le(&self, addr: GuestAddress) -> Result<u32>
fn read_u32_le(&self, addr: GuestAddress) -> Result<u32>
Source§fn read_u64_le(&self, addr: GuestAddress) -> Result<u64>
fn read_u64_le(&self, addr: GuestAddress) -> Result<u64>
Source§fn write_u16_le(&self, addr: GuestAddress, value: u16) -> Result<()>
fn write_u16_le(&self, addr: GuestAddress, value: u16) -> Result<()>
Source§fn write_u32_le(&self, addr: GuestAddress, value: u32) -> Result<()>
fn write_u32_le(&self, addr: GuestAddress, value: u32) -> Result<()>
Source§fn write_u64_le(&self, addr: GuestAddress, value: u64) -> Result<()>
fn write_u64_le(&self, addr: GuestAddress, value: u64) -> Result<()>
Auto Trait Implementations§
impl !Freeze for SliceGuestMemory
impl !RefUnwindSafe for SliceGuestMemory
impl Send for SliceGuestMemory
impl Sync for SliceGuestMemory
impl Unpin for SliceGuestMemory
impl UnsafeUnpin for SliceGuestMemory
impl UnwindSafe for SliceGuestMemory
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more