OuterVm

Trait OuterVm 

Source
pub trait OuterVm {
    type InnerVm: InnerVm;

    // Required methods
    fn get_imported_page(&mut self, address: u64) -> Option<Segment>;
    fn export(&mut self, segment: &[u8]) -> Result<(), ApiError>;
    fn read_file_block(&mut self, block_ref: &BlockRef) -> Option<Bytes>;
    fn get_export_count(&mut self) -> u16;
    fn get_auth_output_len(&mut self) -> u32;
    fn machine(
        &mut self,
        code: &[u8],
        program_counter: u64,
    ) -> Result<Self::InnerVm, ApiError>;

    // Provided methods
    fn read_file(&mut self, block_ref: &BlockRef) -> Result<Vec<u8>, Error> { ... }
    fn block_reader(&mut self) -> Lookup<'_, Self> { ... }
}
Expand description

A trait that abstracts JAM host-calls available in a refine environment and related to an outer VM.

Required Associated Types§

Source

type InnerVm: InnerVm

Inner VM wrapper.

Required Methods§

Source

fn get_imported_page(&mut self, address: u64) -> Option<Segment>

Returns a memory page with the specified address that was imported into work package or None if such page doesn’t exist.

Source

fn export(&mut self, segment: &[u8]) -> Result<(), ApiError>

Export segment from the work package.

The segment length must not be longer than SEGMENT_LEN. If it’s shorter, the rest of of the bytes are zeroed.

Source

fn read_file_block(&mut self, block_ref: &BlockRef) -> Option<Bytes>

Reads file system block specified by its reference.

Source

fn get_export_count(&mut self) -> u16

Returns the number of exports that the current work package has.

Source

fn get_auth_output_len(&mut self) -> u32

Returns the length of the authorizer output.

Source

fn machine( &mut self, code: &[u8], program_counter: u64, ) -> Result<Self::InnerVm, ApiError>

Creates a new inner VM and returns its wrapped handle.

Provided Methods§

Source

fn read_file(&mut self, block_ref: &BlockRef) -> Result<Vec<u8>, Error>

Returns the contents of a file specified by its main block reference.

Uses read_file_block to read file blocks.

Source

fn block_reader(&mut self) -> Lookup<'_, Self>

Returns file system block reader that uses read_file_block to read file blocks.

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§