Trait MemoryTr

pub trait MemoryTr {
    // Required methods
    fn set_data(
        &mut self,
        memory_offset: usize,
        data_offset: usize,
        len: usize,
        data: &[u8],
    );
    fn set(&mut self, memory_offset: usize, data: &[u8]);
    fn size(&self) -> usize;
    fn copy(&mut self, destination: usize, source: usize, len: usize);
    fn slice(&self, range: Range<usize>) -> impl Deref<Target = [u8]>;
    fn resize(&mut self, new_size: usize) -> bool;

    // Provided method
    fn slice_len(&self, offset: usize, len: usize) -> impl Deref<Target = [u8]> { ... }
}
Expand description

Trait for Interpreter memory operations.

Required Methods§

fn set_data( &mut self, memory_offset: usize, data_offset: usize, len: usize, data: &[u8], )

Sets memory data at given offset from data with a given data_offset and len.

§Panics

Panics if range is out of scope of allocated memory.

fn set(&mut self, memory_offset: usize, data: &[u8])

Sets memory data at given offset.

§Panics

Panics if range is out of scope of allocated memory.

fn size(&self) -> usize

Returns memory size.

fn copy(&mut self, destination: usize, source: usize, len: usize)

Copies memory data from source to destination.

§Panics

Panics if range is out of scope of allocated memory.

fn slice(&self, range: Range<usize>) -> impl Deref<Target = [u8]>

Memory slice with range

§Panics

Panics if range is out of scope of allocated memory.

fn resize(&mut self, new_size: usize) -> bool

Resizes memory to new size

§Note

It checks memory limits.

Provided Methods§

fn slice_len(&self, offset: usize, len: usize) -> impl Deref<Target = [u8]>

Memory slice len

Uses slice internally.

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.

Implementations on Foreign Types§

§

impl<T> MemoryTr for Rc<RefCell<T>>
where T: MemoryGetter,

§

fn set_data( &mut self, memory_offset: usize, data_offset: usize, len: usize, data: &[u8], )

§

fn set(&mut self, memory_offset: usize, data: &[u8])

§

fn size(&self) -> usize

§

fn copy(&mut self, destination: usize, source: usize, len: usize)

§

fn slice(&self, range: Range<usize>) -> impl Deref<Target = [u8]>

§

fn resize(&mut self, new_size: usize) -> bool

Implementors§