pub trait MemoryAccess {
// Required methods
fn page_size(&self) -> u64;
fn allocate_page(&mut self) -> MemoryResult<Page>;
fn read_at<D>(&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 zero<E>(
&mut self,
page: Page,
offset: PageOffset,
data: &E,
) -> MemoryResult<()>
where E: Encode;
fn read_at_raw(
&self,
page: Page,
offset: PageOffset,
buf: &mut [u8],
) -> MemoryResult<usize>;
}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 allocate_page(&mut self) -> MemoryResult<Page>
fn allocate_page(&mut self) -> MemoryResult<Page>
Allocates an additional page in memory and returns its number.
Sourcefn read_at<D>(&self, page: Page, offset: PageOffset) -> MemoryResult<D>where
D: Encode,
fn read_at<D>(&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 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 read_at_raw(
&self,
page: Page,
offset: PageOffset,
buf: &mut [u8],
) -> MemoryResult<usize>
fn read_at_raw( &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.
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.