Skip to main content
← PSoXide SDK guides and examples · SDK f2fec1c301f1 · All Cargo features enabled; check feature gates before use.

PageBuffer

Struct PageBuffer 

Source
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>

Source

pub const fn new() -> Self

A zero-filled buffer.

Source

pub const fn page_count(&self) -> usize

Number of pages.

Source

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.

Source

pub fn bytes_mut(&mut self, run: PageRun, len: usize) -> Option<&mut [u8]>

Mutable form of PageBuffer::bytes.

Source

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.

Source

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.

Source

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.

Trait Implementations§

Source§

impl<const PAGES: usize> Default for PageBuffer<PAGES>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<const PAGES: usize> Freeze for PageBuffer<PAGES>

§

impl<const PAGES: usize> RefUnwindSafe for PageBuffer<PAGES>

§

impl<const PAGES: usize> Send for PageBuffer<PAGES>

§

impl<const PAGES: usize> Sync for PageBuffer<PAGES>

§

impl<const PAGES: usize> Unpin for PageBuffer<PAGES>

§

impl<const PAGES: usize> UnsafeUnpin for PageBuffer<PAGES>

§

impl<const PAGES: usize> UnwindSafe for PageBuffer<PAGES>

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

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

§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.