pub trait MemoryAccess {
// Required methods
fn page_size(&self) -> u64;
fn grow_one_page(&mut self) -> MemoryResult<Page>;
fn zero_page(&mut self, page: Page) -> MemoryResult<()>;
fn read_at<D>(&mut self, page: Page, offset: PageOffset) -> MemoryResult<D>
where D: Encode;
fn write_at<E>(
&mut self,
page: Page,
offset: PageOffset,
data: &E,
) -> MemoryResult<()>
where E: Encode;
fn write_at_raw(
&mut self,
page: Page,
offset: PageOffset,
buf: &[u8],
) -> MemoryResult<()>;
fn zero<E>(
&mut self,
page: Page,
offset: PageOffset,
data: &E,
) -> MemoryResult<()>
where E: Encode;
fn zero_raw(
&mut self,
page: Page,
offset: PageOffset,
len: PageOffset,
) -> MemoryResult<()>;
fn read_at_raw(
&mut self,
page: Page,
offset: PageOffset,
buf: &mut [u8],
) -> MemoryResult<usize>;
// Provided methods
fn claim_page(&mut self) -> MemoryResult<Page> { ... }
fn unclaim_page(&mut self, page: Page) -> MemoryResult<()> { ... }
}Expand description
Abstraction over page-level memory operations.
All table-registry and ledger functions are generic over this trait so that callers can transparently add write-ahead journaling or other interceptors without modifying the memory crate.
Required Methods§
Sourcefn 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.
The returned page is zero-initialized. This primitive is not
journaled — page growth cannot be rolled back, so a transaction
that aborts after a grow_one_page simply leaks the new page.
Sourcefn 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.
Sourcefn 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.
Sourcefn 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.
Sourcefn 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.
Sourcefn 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.
Sourcefn 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.
Used by the migration apply pipeline when scrubbing a record whose size is known only at runtime (from a stored snapshot).
Sourcefn 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.
Returns the number of bytes actually read.
Provided Methods§
Sourcefn claim_page(&mut self) -> MemoryResult<Page>
fn claim_page(&mut self) -> MemoryResult<Page>
Hands out a page for use by a caller.
Reuses a page from the unclaimed-pages ledger when one is available; otherwise grows the memory by one page.
Sourcefn 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.
The page contents are zeroed before being published to the ledger.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.