Struct guestmem::ranges::PagedRange
source · pub struct PagedRange<'a> { /* private fields */ }
Expand description
A range of guest memory spanning multiple discontiguous pages.
This is represented by an offset, a length, and a list of pages. The range may span the first and last pages only partially, but the interior pages are completely covered by the range.
Implementations§
source§impl<'a> PagedRange<'a>
impl<'a> PagedRange<'a>
sourcepub const fn new(offset: usize, len: usize, gpns: &'a [u64]) -> Option<Self>
pub const fn new(offset: usize, len: usize, gpns: &'a [u64]) -> Option<Self>
Creates a new range over gpns
, starting at offset
bytes into the page list, extending for len
bytes.
Returns None
if offset
or len
are out of bounds.
sourcepub fn try_subrange(&self, offset: usize, len: usize) -> Option<Self>
pub fn try_subrange(&self, offset: usize, len: usize) -> Option<Self>
Returns a subrange of this range, or None
if the subrange is outside this range.
sourcepub fn subrange(&self, offset: usize, len: usize) -> Self
pub fn subrange(&self, offset: usize, len: usize) -> Self
Returns a subrange of this range.
Panics if the subrange is outside this range.
sourcepub fn skip(&mut self, len: usize)
pub fn skip(&mut self, len: usize)
Skips the first len
bytes of the range.
Panics if len
is larger than the range’s length.
sourcepub fn truncate(&mut self, len: usize)
pub fn truncate(&mut self, len: usize)
Truncates the range to len
bytes.
Panics if len
is larger than the range’s length.
sourcepub fn split(self, offset: usize) -> (Self, Self)
pub fn split(self, offset: usize) -> (Self, Self)
Splits the range at offset
.
Panics if offset
is outside the range.
sourcepub fn try_split(self, offset: usize) -> Option<(Self, Self)>
pub fn try_split(self, offset: usize) -> Option<(Self, Self)>
Splits the range at offset
, returning None
if offset
is outside
the range.
sourcepub fn pop_front_range(&mut self) -> Option<Result<AddressRange, InvalidGpn>>
pub fn pop_front_range(&mut self) -> Option<Result<AddressRange, InvalidGpn>>
Removes and returns the first contiguous range.
sourcepub fn reader(self, mem: &'a GuestMemory) -> PagedRangeReader<'a>
pub fn reader(self, mem: &'a GuestMemory) -> PagedRangeReader<'a>
Returns a MemoryRead
implementation.
sourcepub fn writer(self, mem: &'a GuestMemory) -> PagedRangeWriter<'a>
pub fn writer(self, mem: &'a GuestMemory) -> PagedRangeWriter<'a>
Returns a MemoryWrite
implementation.
sourcepub fn ranges(self) -> PagedRangeRangeIter<'a> ⓘ
pub fn ranges(self) -> PagedRangeRangeIter<'a> ⓘ
Returns an iterator over the AddressRange
s represented by this
range.
Trait Implementations§
source§impl<'a> Clone for PagedRange<'a>
impl<'a> Clone for PagedRange<'a>
source§fn clone(&self) -> PagedRange<'a>
fn clone(&self) -> PagedRange<'a>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl<'a> Debug for PagedRange<'a>
impl<'a> Debug for PagedRange<'a>
impl<'a> Copy for PagedRange<'a>
Auto Trait Implementations§
impl<'a> Freeze for PagedRange<'a>
impl<'a> RefUnwindSafe for PagedRange<'a>
impl<'a> Send for PagedRange<'a>
impl<'a> Sync for PagedRange<'a>
impl<'a> Unpin for PagedRange<'a>
impl<'a> UnwindSafe for PagedRange<'a>
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)