Skip to main content

OuterVm

Trait OuterVm 

Source
pub trait OuterVm {
    type InnerVm: InnerVm;

    // Required methods
    fn export(&mut self, segment: &[u8; 4104]) -> Result<(), ApiError>;
    fn read_file_block(&mut self, block_ref: &BlockRef) -> Option<Bytes>;
    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 export(&mut self, segment: &[u8; 4104]) -> 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 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".

Implementors§