mirror of
https://github.com/Xevion/Pac-Man.git
synced 2025-12-16 16:12:37 -06:00
docs: document many major functions, types, enums for important functionality
This commit is contained in:
@@ -10,29 +10,29 @@ mod desktop;
|
||||
#[cfg(target_os = "emscripten")]
|
||||
mod emscripten;
|
||||
|
||||
/// Platform abstraction trait that defines cross-platform functionality.
|
||||
/// Cross-platform abstraction layer providing unified APIs for platform-specific operations.
|
||||
pub trait CommonPlatform {
|
||||
/// Sleep for the specified duration using platform-appropriate method.
|
||||
/// Platform-specific sleep function (required due to Emscripten's non-standard sleep requirements).
|
||||
///
|
||||
/// Provides access to current window focus state, useful for changing sleep algorithm conditionally.
|
||||
fn sleep(&self, duration: Duration, focused: bool);
|
||||
|
||||
/// Get the current time in seconds since some reference point.
|
||||
/// This is available for future use in timing and performance monitoring.
|
||||
#[allow(dead_code)]
|
||||
fn get_time(&self) -> f64;
|
||||
|
||||
/// Initialize platform-specific console functionality.
|
||||
/// Configures platform-specific console and debugging output capabilities.
|
||||
fn init_console(&self) -> Result<(), PlatformError>;
|
||||
|
||||
/// Get canvas size for platforms that need it (e.g., Emscripten).
|
||||
/// This is available for future use in responsive design.
|
||||
/// Retrieves the actual display canvas dimensions.
|
||||
#[allow(dead_code)]
|
||||
fn get_canvas_size(&self) -> Option<(u32, u32)>;
|
||||
|
||||
/// Load asset bytes using platform-appropriate method.
|
||||
/// Loads raw asset data using the appropriate platform-specific method.
|
||||
|
||||
fn get_asset_bytes(&self, asset: Asset) -> Result<Cow<'static, [u8]>, AssetError>;
|
||||
}
|
||||
|
||||
/// Get the current platform implementation.
|
||||
/// Returns the appropriate platform implementation based on compile-time target.
|
||||
#[allow(dead_code)]
|
||||
pub fn get_platform() -> &'static dyn CommonPlatform {
|
||||
#[cfg(not(target_os = "emscripten"))]
|
||||
|
||||
Reference in New Issue
Block a user