pub struct MemoryManager<P>where
P: MemoryProvider,{ /* private fields */ }Expand description
The memory manager handles page-level memory operations on top of a
MemoryProvider.
Implementations§
Source§impl<P> MemoryManager<P>where
P: MemoryProvider,
impl<P> MemoryManager<P>where
P: MemoryProvider,
Sourcepub fn init(provider: P) -> Self
pub fn init(provider: P) -> Self
Initializes the memory manager and allocates the header and reserved pages.
§Panics
Panics if the memory provider fails to initialize.
Sourcepub const fn schema_page(&self) -> Page
pub const fn schema_page(&self) -> Page
Returns the schema page.
Sourcepub const fn unclaimed_pages_page(&self) -> Page
pub const fn unclaimed_pages_page(&self) -> Page
Returns the unclaimed-pages ledger page.
Sourcepub fn pages_count(&self) -> u64
pub fn pages_count(&self) -> u64
Returns the total number of pages currently backed by the provider.
Trait Implementations§
Source§impl<P> MemoryAccess for MemoryManager<P>where
P: MemoryProvider,
impl<P> MemoryAccess for MemoryManager<P>where
P: MemoryProvider,
Source§fn grow_one_page(&mut self) -> MemoryResult<Page>
fn grow_one_page(&mut self) -> MemoryResult<Page>
Grows the underlying memory by exactly one page and returns the
freshly allocated page number. Read more
Source§fn zero_page(&mut self, page: Page) -> MemoryResult<()>
fn zero_page(&mut self, page: Page) -> MemoryResult<()>
Zeros out an entire page. Used by
MemoryAccess::unclaim_page
to scrub residual data before publishing the page to the
unclaimed-pages ledger.Source§fn read_at<D>(&mut self, page: Page, offset: PageOffset) -> MemoryResult<D>where
D: Encode,
fn read_at<D>(&mut self, page: Page, offset: PageOffset) -> MemoryResult<D>where
D: Encode,
Reads a typed value from the specified page and offset.
Source§fn write_at<E>(
&mut self,
page: Page,
offset: PageOffset,
data: &E,
) -> MemoryResult<()>where
E: Encode,
fn write_at<E>(
&mut self,
page: Page,
offset: PageOffset,
data: &E,
) -> MemoryResult<()>where
E: Encode,
Writes a typed value at the specified page and offset.
Source§fn write_at_raw(
&mut self,
page: Page,
offset: PageOffset,
buf: &[u8],
) -> MemoryResult<()>
fn write_at_raw( &mut self, page: Page, offset: PageOffset, buf: &[u8], ) -> MemoryResult<()>
Writes raw bytes at the specified page and offset, bypassing
alignment and encoding checks.
Source§fn zero<E>(
&mut self,
page: Page,
offset: PageOffset,
data: &E,
) -> MemoryResult<()>where
E: Encode,
fn zero<E>(
&mut self,
page: Page,
offset: PageOffset,
data: &E,
) -> MemoryResult<()>where
E: Encode,
Zeros out the region occupied by
data at the specified page
and offset.Source§fn zero_raw(
&mut self,
page: Page,
offset: PageOffset,
len: PageOffset,
) -> MemoryResult<()>
fn zero_raw( &mut self, page: Page, offset: PageOffset, len: PageOffset, ) -> MemoryResult<()>
Zeros out
len raw bytes at the specified page and offset. Read moreSource§fn read_at_raw(
&mut self,
page: Page,
offset: PageOffset,
buf: &mut [u8],
) -> MemoryResult<usize>
fn read_at_raw( &mut self, page: Page, offset: PageOffset, buf: &mut [u8], ) -> MemoryResult<usize>
Reads raw bytes into
buf at the specified page and offset. Read moreSource§fn claim_page(&mut self) -> MemoryResult<Page>
fn claim_page(&mut self) -> MemoryResult<Page>
Hands out a page for use by a caller. Read more
Source§fn unclaim_page(&mut self, page: Page) -> MemoryResult<()>
fn unclaim_page(&mut self, page: Page) -> MemoryResult<()>
Returns
page to the unclaimed-pages ledger so it can be reused
by a future MemoryAccess::claim_page call. Read moreAuto Trait Implementations§
impl<P> Freeze for MemoryManager<P>where
P: Freeze,
impl<P> RefUnwindSafe for MemoryManager<P>where
P: RefUnwindSafe,
impl<P> Send for MemoryManager<P>where
P: Send,
impl<P> Sync for MemoryManager<P>where
P: Sync,
impl<P> Unpin for MemoryManager<P>where
P: Unpin,
impl<P> UnsafeUnpin for MemoryManager<P>where
P: UnsafeUnpin,
impl<P> UnwindSafe for MemoryManager<P>where
P: UnwindSafe,
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