stak_vm/primitive_set.rs
1use crate::{Exception, memory::Memory};
2
3/// A primitive set.
4///
5/// [`PrimitiveSet`](PrimitiveSet)s provide primitive functionalities, such as
6/// arithmetic and I/O, to [`Vm`](super::Vm)s. Each primitive has its own
7/// identifier.
8pub trait PrimitiveSet: Sized {
9 /// An error.
10 type Error: Exception;
11
12 /// Runs a primitive on a virtual machine.
13 fn operate(&mut self, memory: &mut Memory, primitive: usize) -> Result<(), Self::Error>;
14}