Skip to main content

Module platform

Module platform 

Source
Expand description

Platform abstraction layer — time, keyboard, and sleep.

The Platform trait decouples the emulator core from the host OS. This lets the same crate::emulator::Emulator run identically on POSIX systems, Windows, and inside a WebAssembly sandbox — each with its own implementation of this trait.

§Implementations

TargetTypeNotes
Linux / macOSposix_platform::PosixPlatformUses libc for time, terminal raw mode, and stdin
Windowswindows_platform::WindowsPlatformUses QueryPerformanceCounter and _kbhit/_getch
WebAssemblywasm::WasmPlatform (private)Uses web_sys::Performance; keyboard fed via JS callbacks

§Adding a new platform

Implement Platform for your type and pass it to crate::emulator::Emulator::run. No other changes are needed.

Modules§

posix_platform

Traits§

Platform
Host platform interface used by the emulator for time, I/O, and sleep.