xio_instructionset 0.5.0

XIO instructionset data structures
Documentation
use ommui_file_loading::{load_json, Error};
use {std, InstructionMap};

type Result<T> = std::result::Result<T, Error>;

/// A handle to a directory containing an instruction set.
#[derive(Debug, Clone, PartialEq)]
pub struct InstructionSet {
    path: String,
}

impl InstructionSet {
    /// Create a new instruction set handle pointing to a directory.
    pub fn new(instructionset_path: &str) -> Self {
        InstructionSet {
            path: instructionset_path.to_string(),
        }
    }

    /// Load the instructions.
    pub fn load_instructions(&self) -> Result<InstructionMap> {
        load_json(&format!("{}/instructionset.json", self.path))
    }
}