From e4656ac0813df219f833cda46036ad135f740bfa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Magalh=C3=A3es?= <joamag@gmail.com> Date: Sat, 10 Aug 2024 11:11:21 +0100 Subject: [PATCH] chore: initial state component definition --- src/state.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/state.rs b/src/state.rs index 98c71aeb..4562be96 100644 --- a/src/state.rs +++ b/src/state.rs @@ -50,6 +50,20 @@ pub const BOS_VERSION: u8 = 1; /// Magic number for the BESS file format. pub const BESS_MAGIC: u32 = 0x53534542; +/// Represents a component that is able to store and retrieve +/// the state of its internal structure. +/// +/// This trait is used to define the behavior of the state +/// components that are used to store the emulator state. +/// +/// Ideally each of Game Boy's components should implement +/// this trait to allow the state to be saved and restored +/// in a consistent way. +pub trait StateComponent { + fn get_state(&self) -> Result<Vec<u8>, Error>; + fn set_state(&mut self, data: &[u8]) -> Result<(), Error>; +} + #[cfg_attr(feature = "wasm", wasm_bindgen)] pub enum SaveStateFormat { /// Boytacean Save Compressed format (BOSC). -- GitLab