pub struct OneFpgaCore { /* private fields */ }Expand description
A core that be used in the 1FPGA platform. This is a wrapper around a core
that implements the Core trait. It can be used to pass around a core
without knowing its implementation.
§Safety
We can use UnsafeCell here because we are not sharing the core across threads. Although this can still lead to undefined behaviour, the underlying core still has access to physical memory and this does not make it less safe.
Implementations§
Trait Implementations§
Source§impl Clone for OneFpgaCore
impl Clone for OneFpgaCore
Source§fn clone(&self) -> OneFpgaCore
fn clone(&self) -> OneFpgaCore
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Core for OneFpgaCore
impl Core for OneFpgaCore
Source§fn init(&mut self) -> Result<(), Error>
fn init(&mut self) -> Result<(), Error>
Initialize the core and anything needed for it to run.
Source§fn reset(&mut self) -> Result<(), Error>
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>
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 screenshot(&self) -> Result<DynamicImage, Error>
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>
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>
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>
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_bios(&mut self, bios: Bios) -> Result<(), Error>
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 keys_set(&mut self, keys: ScancodeSet) -> Result<(), Error>
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>
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.
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>
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>
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>
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>
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>
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).
fn as_any(&self) -> &dyn Any
fn as_any_mut(&mut self) -> &mut dyn Any
Source§fn quit(&mut self)
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
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.
Auto Trait Implementations§
impl Freeze for OneFpgaCore
impl !RefUnwindSafe for OneFpgaCore
impl !Send for OneFpgaCore
impl !Sync for OneFpgaCore
impl Unpin for OneFpgaCore
impl !UnwindSafe for OneFpgaCore
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more