pub trait PlatformProvider {
    // Required methods
    fn request_window(&self, config: WindowConfig);
    fn get_key_state(&self) -> KeyState<KeyPosition>;
    fn get_virtual_key_state(&self) -> KeyState<VirtualKey>;
    fn get_joystick_state(&self) -> JoystickState;
    fn print(&self, text: &str);
    fn input(&self) -> String;
    fn random(&self) -> u8;
}

Required Methods§

source

fn request_window(&self, config: WindowConfig)

Request that the platform create a window of the specified size, with the specified scale factor. If a window already exists, the platform should resize it to the new size.

source

fn get_key_state(&self) -> KeyState<KeyPosition>

Get the current state of the user’s physical keyboard.

source

fn get_virtual_key_state(&self) -> KeyState<VirtualKey>

Get the state of a virtual keyboard (emulating the target system), if one is available.

source

fn get_joystick_state(&self) -> JoystickState

Get the current state of the connected joystick. If no joystick is connected, this should return a default state.

source

fn print(&self, text: &str)

Display the given string to the user, “out-of-band” from any other graphics. This is used for text-mode systems. Implementations may choose various ways to display this, such as a terminal message or a pop-up.

source

fn input(&self) -> String

Read a string input from the user, “out-of-band” from any other graphics. This is used for text-mode systems. Implementations may choose various ways to prompt for this, such as a terminal prompt or a pop-up dialog.

source

fn random(&self) -> u8

Return a random number between 0 and 255. This exists as some platforms (such as the web) have a different source of randomness.

Implementors§