pub trait Memory {
// Required methods
fn size(&self) -> u64;
fn grow(&self, pages: u64) -> i64;
fn read(&self, offset: u64, bytes: &mut [u8]);
fn write(&self, offset: u64, bytes: &[u8]);
// Provided method
unsafe fn read_unsafe(&self, offset: u64, dst: *mut u8, count: usize) { ... }
}Expand description
Memory
Page-addressed backing for Storage. Growth returns the previous page count, or -1 without changing memory. Successful growth adds zero-filled pages. Reads and writes must reject the complete out-of-bounds range before IO. Implementing this trait alone does not grant allocation authority.
Required Methods§
Provided Methods§
Sourceunsafe fn read_unsafe(&self, offset: u64, dst: *mut u8, count: usize)
unsafe fn read_unsafe(&self, offset: u64, dst: *mut u8, count: usize)
Read into a potentially uninitialized destination, following ICSS’s hook.
Every implementation must initialize all count bytes on successful
return. A failed read may leave a partially initialized destination.
The default supports existing backings through Self::read; overrides
can avoid zeroing bytes that backing IO will overwrite.
§Safety
The caller must provide an exclusive writable count-byte range valid
for a Rust slice. It must not overlap this memory’s state or read source.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".