Skip to main content

VM

Struct VM 

Source
pub struct VM {
    pub registers: [i32; 32],
    pub float_registers: [f64; 32],
    pub program: Vec<u8>,
    pub logical_cores: usize,
    pub alias: Option<String>,
    pub connection_manager: Arc<RwLock<Manager>>,
    pub id: Uuid,
    pub server_port: Option<String>,
    /* private fields */
}
Expand description

Virtual machine struct that will execute bytecode

Fields§

§registers: [i32; 32]

Array that simulates having hardware registers

§float_registers: [f64; 32]

Array that simulates having floating point hardware registers

§program: Vec<u8>

The bytecode of the program being run

§logical_cores: usize

Number of logical cores the system reports

§alias: Option<String>

An alias that can be specified by the user and used to refer to the Node

§connection_manager: Arc<RwLock<Manager>>

Data structure to manage remote clients

§id: Uuid

Is a unique, randomly generated UUID for identifying this VM

§server_port: Option<String>

Port the server will bind to for server-to-server communications

Implementations§

Source§

impl VM

Source

pub fn new() -> VM

Creates and returns a new VM

Source

pub fn run(&mut self) -> Vec<VMEvent>

Wraps execution in a loop so it will continue to run until done or there is an error executing instructions.

Source

pub fn with_alias(self, alias: String) -> Self

Source

pub fn with_cluster_bind(self, server_addr: String, server_port: String) -> Self

Source

pub fn run_once(&mut self)

Executes one instruction. Meant to allow for more controlled execution of the VM

Source

pub fn add_byte(&mut self, b: u8)

Adds an arbitrary byte to the VM’s program

Source

pub fn add_bytes(&mut self, b: Vec<u8>)

Adds an arbitrary byte to the VM’s program

Source

pub fn print_i32_register(&self, register: usize)

Source

pub fn get_test_vm() -> VM

Source

pub fn prepend_header(b: Vec<u8>) -> Vec<u8>

Source

pub fn bind_cluster_server(&mut self)

Trait Implementations§

Source§

impl Clone for VM

Source§

fn clone(&self) -> VM

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Default for VM

Source§

fn default() -> VM

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl Freeze for VM

§

impl RefUnwindSafe for VM

§

impl Send for VM

§

impl Sync for VM

§

impl Unpin for VM

§

impl UnsafeUnpin for VM

§

impl UnwindSafe for VM

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.