Core

Trait Core 

Source
pub trait Core {
Show 28 methods // Required methods fn init(&mut self) -> Result<(), Error>; fn name(&self) -> &str; fn reset(&mut self) -> Result<(), Error>; fn set_volume(&mut self, volume: u8) -> Result<(), Error>; fn set_rtc(&mut self, time: SystemTime) -> Result<(), Error>; fn screenshot(&self) -> Result<DynamicImage, Error>; fn save_state_mut( &mut self, slot: usize, ) -> Result<Option<&mut dyn SaveState>, Error>; fn save_state(&self, slot: usize) -> Result<Option<&dyn SaveState>, Error>; fn mounted_file_mut( &mut self, slot: usize, ) -> Result<Option<&mut dyn MountedFile>, Error>; fn send_rom(&mut self, rom: Rom) -> Result<(), Error>; fn send_bios(&mut self, bios: Bios) -> Result<(), Error>; fn key_up(&mut self, key: Scancode) -> Result<(), Error>; fn key_down(&mut self, key: Scancode) -> Result<(), Error>; fn keys_set(&mut self, keys: ScancodeSet) -> Result<(), Error>; fn keys(&self) -> Result<ScancodeSet, Error>; fn gamepad_button_up( &mut self, index: usize, button: Button, ) -> Result<(), Error>; fn gamepad_button_down( &mut self, index: usize, button: Button, ) -> Result<(), Error>; fn gamepad_buttons_set( &mut self, index: usize, buttons: ButtonSet, ) -> Result<(), Error>; fn gamepad_buttons(&self, index: usize) -> Result<Option<ButtonSet>, Error>; fn settings(&self) -> Result<CoreSettings, Error>; fn trigger(&mut self, id: SettingId) -> Result<(), Error>; fn file_select(&mut self, id: SettingId, path: String) -> Result<(), Error>; fn int_option(&mut self, id: SettingId, value: u32) -> Result<u32, Error>; fn bool_option(&mut self, id: SettingId, value: bool) -> Result<bool, Error>; fn as_any(&self) -> &dyn Any; fn as_any_mut(&mut self) -> &mut dyn Any; fn quit(&mut self); fn should_quit(&self) -> bool;
}

Required Methods§

Source

fn init(&mut self) -> Result<(), Error>

Initialize the core and anything needed for it to run.

Source

fn name(&self) -> &str

Return a human-readable name for the core.

Source

fn reset(&mut self) -> Result<(), Error>

Reset the core, restarting the ROM from the beginning.

Source

fn set_volume(&mut self, volume: u8) -> Result<(), Error>

Update the volume of a core. This value is to be taken as a linear scale from 0-256 requested from the user. If the core takes a logarithmic scale, it should convert it to the appropriate value.

Source

fn set_rtc(&mut self, time: SystemTime) -> Result<(), Error>

Sets the time in the core’s RTC.

Source

fn screenshot(&self) -> Result<DynamicImage, Error>

Take a screenshot (if supported), returning the image.

Source

fn save_state_mut( &mut self, slot: usize, ) -> Result<Option<&mut dyn SaveState>, Error>

Get the save state at a specific slot. If the core does not support save states, this should return None for all slots. If the core supports save states, but the slot index is out of bound, this should return None.

Source

fn save_state(&self, slot: usize) -> Result<Option<&dyn SaveState>, Error>

Get the save state at a specific slot. If the core does not support save states, this should return None for all slots. If the core supports save states, but the slot index is out of bound, this should return None.

Source

fn mounted_file_mut( &mut self, slot: usize, ) -> Result<Option<&mut dyn MountedFile>, Error>

Get the mounted save file at a specific slot. If the core does not support mounting files, this should return None for all slots. If the core supports mounting files, but the slot index is out of bound, this should return None.

Source

fn send_rom(&mut self, rom: Rom) -> Result<(), Error>

Load a ROM into the core.

Source

fn send_bios(&mut self, bios: Bios) -> Result<(), Error>

Load a BIOS into the core. For cores that support multiple BIOS, the BIOS should be selected based on the core’s configuration and the slot information should be part of [&dyn Bios].

Source

fn key_up(&mut self, key: Scancode) -> Result<(), Error>

Send a key up event to the core.

Source

fn key_down(&mut self, key: Scancode) -> Result<(), Error>

Send a key down event to the core.

Source

fn keys_set(&mut self, keys: ScancodeSet) -> Result<(), Error>

Set the keys that are currently pressed, releasing the keys that are not in the list.

Source

fn keys(&self) -> Result<ScancodeSet, Error>

Return a slice of the keys that are currently pressed. The order of the keys in the slice is not guaranteed.

Source

fn gamepad_button_up( &mut self, index: usize, button: Button, ) -> Result<(), Error>

Source

fn gamepad_button_down( &mut self, index: usize, button: Button, ) -> Result<(), Error>

Source

fn gamepad_buttons_set( &mut self, index: usize, buttons: ButtonSet, ) -> Result<(), Error>

Source

fn gamepad_buttons(&self, index: usize) -> Result<Option<ButtonSet>, Error>

Returns the gamepad buttons that are currently pressed. The order of the buttons in the slice is not guaranteed. If the core does not support gamepads at the index requested, this should return None.

Source

fn settings(&self) -> Result<CoreSettings, Error>

Returns the menu items that the core supports. This would correspond to the top level page of config items. If the core does not support a menu, this should return an empty vector.

Source

fn trigger(&mut self, id: SettingId) -> Result<(), Error>

Trigger a menu item in the core. This is used to perform an action based on the menu item selected by the user. It can also be linked to a shortcut.

Source

fn file_select(&mut self, id: SettingId, path: String) -> Result<(), Error>

Send a file path to the core. This is used to load files into the core.

Source

fn int_option(&mut self, id: SettingId, value: u32) -> Result<u32, Error>

Set an integer option in the core. This is used to set an option that has a positive integer value. Returns the new value (e.g. if value is out of bound, the core might clip it or reset it).

Source

fn bool_option(&mut self, id: SettingId, value: bool) -> Result<bool, Error>

Set a boolean option in the core. This is used to set an option that has a boolean value that can be toggled by the user. Returns the new value (e.g. if the core cannot change the value, returns the previous one).

Source

fn as_any(&self) -> &dyn Any

Source

fn as_any_mut(&mut self) -> &mut dyn Any

Source

fn quit(&mut self)

Indicates to the core that it needs to prepare quitting. This is used to perform any cleanup that the core needs to do before quitting. When the core is ready, [should_quit()] should return true.

Source

fn should_quit(&self) -> bool

Returns true if the core should quit. Some cores might want to quit back to the main menu by themselves.

Implementors§