Skip to main content

Memory

Trait Memory 

Source
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]);
}
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§

Source

fn size(&self) -> u64

Current extent in 65,536-byte pages.

Source

fn grow(&self, pages: u64) -> i64

Add zero-filled pages, or return -1 on refusal.

Source

fn read(&self, offset: u64, bytes: &mut [u8])

Read an admitted byte range.

Source

fn write(&self, offset: u64, bytes: &[u8])

Write an admitted byte range. Native writes need not be transactional.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl Memory for RefCell<Vec<u8>>

Source§

fn size(&self) -> u64

Source§

fn grow(&self, pages: u64) -> i64

Source§

fn read(&self, offset: u64, bytes: &mut [u8])

Source§

fn write(&self, offset: u64, bytes: &[u8])

Source§

impl<M: Memory + ?Sized> Memory for &M

Source§

fn size(&self) -> u64

Source§

fn grow(&self, pages: u64) -> i64

Source§

fn read(&self, offset: u64, bytes: &mut [u8])

Source§

fn write(&self, offset: u64, bytes: &[u8])

Source§

impl<M: Memory + ?Sized> Memory for Rc<M>

Source§

fn size(&self) -> u64

Source§

fn grow(&self, pages: u64) -> i64

Source§

fn read(&self, offset: u64, bytes: &mut [u8])

Source§

fn write(&self, offset: u64, bytes: &[u8])

Implementors§