pub struct PageBuffer<const PAGES: usize> { /* private fields */ }Expand description
PAGES pages of PAGE_BYTES bytes, word aligned and contiguous.
Pair it with a crate::PagePool of the same capacity: the pool decides
which pages belong to which allocation, the buffer owns the bytes. The
all-zero image means a static buffer stays in .bss rather than the
executable.
A byte view borrows the buffer, so it cannot outlive it, but it describes
its run only until the pool compacts or the run is freed and reused:
re-resolve through crate::Residency::try_run each use unless the entry
is pinned.
Implementations§
Source§impl<const PAGES: usize> PageBuffer<PAGES>
impl<const PAGES: usize> PageBuffer<PAGES>
Sourcepub const fn page_count(&self) -> usize
pub const fn page_count(&self) -> usize
Number of pages.
Sourcepub fn bytes(&self, run: PageRun, len: usize) -> Option<&[u8]>
pub fn bytes(&self, run: PageRun, len: usize) -> Option<&[u8]>
The first len bytes of run, or None when the run is outside the
buffer or shorter than len.
Sourcepub fn bytes_mut(&mut self, run: PageRun, len: usize) -> Option<&mut [u8]>
pub fn bytes_mut(&mut self, run: PageRun, len: usize) -> Option<&mut [u8]>
Mutable form of PageBuffer::bytes.
Sourcepub fn write(&mut self, run: PageRun, offset: usize, data: &[u8]) -> bool
pub fn write(&mut self, run: PageRun, offset: usize, data: &[u8]) -> bool
Copy data to offset bytes into run. false when it does not fit.
Sourcepub fn move_pages(&mut self, from: PageRun, to_page: u32) -> bool
pub fn move_pages(&mut self, from: PageRun, to_page: u32) -> bool
Move from to start at to_page (a memmove: the ranges may
overlap). The owner calls this for each crate::PagePool::compact_step.
false when either range is outside the buffer.
Sourcepub fn page_address(&mut self, page: u32) -> Option<*mut u8>
pub fn page_address(&mut self, page: u32) -> Option<*mut u8>
Address of the first byte of page, for a transport that lands
sectors in place. None past the end.