Memory

Trait Memory 

Source
pub trait Memory {
    // Required methods
    fn size(&self) -> u64;
    fn grow(&self, pages: u64) -> i64;
    fn read(&self, offset: u64, dst: &mut [u8]);
    fn write(&self, offset: u64, src: &[u8]);
}

Required Methods§

Source

fn size(&self) -> u64

Returns the current size of the stable memory in WebAssembly pages. (One WebAssembly page is 64Ki bytes.)

Source

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

Tries to grow the memory by new_pages many pages containing zeroes. If successful, returns the previous size of the memory (in pages). Otherwise, returns -1.

Source

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

Copies the data referred to by offset out of the stable memory and replaces the corresponding bytes in dst.

Source

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

Copies the data referred to by src and replaces the corresponding segment starting at offset in the stable memory.

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, dst: &mut [u8])

Source§

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

Source§

impl<M: Memory> Memory for Rc<M>

Source§

fn size(&self) -> u64

Source§

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

Source§

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

Source§

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

Implementors§