Trait MemoryTr

Source
pub trait MemoryTr {
    // Required methods
    fn set_data(
        &mut self,
        memory_offset: usize,
        data_offset: usize,
        len: usize,
        data: &[u8],
    );
    fn set_data_from_global(
        &mut self,
        memory_offset: usize,
        data_offset: usize,
        len: usize,
        data_range: Range<usize>,
    );
    fn global_slice(&self, range: Range<usize>) -> Ref<'_, [u8]>;
    fn local_memory_offset(&self) -> usize;
    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>) -> Ref<'_, [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§

Source

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.

Source

fn set_data_from_global( &mut self, memory_offset: usize, data_offset: usize, len: usize, data_range: Range<usize>, )

Inner clone part of memory from global context to local context. This is used to clone calldata to memory.

§Panics

Panics if range is out of scope of allocated memory.

Source

fn global_slice(&self, range: Range<usize>) -> Ref<'_, [u8]>

Memory slice with global range. This range

§Panics

Panics if range is out of scope of allocated memory.

Source

fn local_memory_offset(&self) -> usize

Offset of local context of memory.

Source

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.

Source

fn size(&self) -> usize

Returns memory size.

Source

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.

Source

fn slice(&self, range: Range<usize>) -> Ref<'_, [u8]>

Memory slice with range

§Panics

Panics if range is out of scope of allocated memory.

Source

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

Resizes memory to new size

§Note

It checks memory limits.

Provided Methods§

Source

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.

Implementors§