stak_vm/
primitive_set.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
use crate::{memory::Memory, Error};
use core::error;

/// A primitive set.
///
/// [`PrimitiveSet`](PrimitiveSet)s provide primitive functionalities, such as
/// arithmetic and I/O, to [`Vm`](super::Vm)s. Each primitive has its own
/// identifier.
pub trait PrimitiveSet: Sized {
    /// An error.
    type Error: From<Error> + error::Error;

    /// Runs a primitive on a virtual machine.
    fn operate(&mut self, memory: &mut Memory, primitive: usize) -> Result<(), Self::Error>;
}