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 AddressRanges 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 more