diff --git a/src/state.rs b/src/state.rs index 98c71aeb723148c16ecd342e9a8e091f015102de..4562be96206fa3b395d0c642a9e128da2471cddb 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).