0.1.0-1-alpha.1

This commit is contained in:
2026-09-16 23:13:26 +02:00
parent 9197758184
commit 2ad0c5a379
14 changed files with 402 additions and 16 deletions

View File

@@ -0,0 +1,122 @@
// file: crates/engines/engine-v1-platform-api/src/environment.rs
// version: 1
/// Broad physical device class relevant to interaction and score provenance.
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum DeviceClass {
/// Conventional desktop or laptop computer.
Desktop,
/// Phone-sized touch device.
Phone,
/// Tablet-sized touch device.
Tablet,
/// Device class is intentionally unknown or not yet classified.
Unknown,
}
/// Code execution model used by the game runtime.
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum ExecutionModel {
/// Native machine code for the target platform.
Native,
/// WebAssembly execution.
Wasm,
}
/// Primary control profile relevant to gameplay comparability.
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum InputProfile {
/// Gamepad or equivalent controller is the primary input.
Gamepad,
/// Keyboard and mouse are the primary input devices.
KeyboardMouse,
/// Multiple materially different input modes are active for the same session.
Mixed,
/// Touchscreen or touch gestures are the primary input.
Touch,
/// Input profile is intentionally unknown or not yet classified.
Unknown,
}
/// Broad platform family hosting the game.
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum PlatformFamily {
/// Android application environment.
Android,
/// Desktop operating-system environment.
Desktop,
/// Browser-oriented Web environment.
Web,
}
/// Host container in which the game runtime executes.
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum RuntimeHost {
/// Conventional Web browser.
Browser,
/// Native process managed directly by the operating system.
Native,
/// Tauri desktop WebView host.
TauriWebView,
}
/// Descriptive provenance attached to one runtime session.
///
/// This structure is intentionally descriptive: it does not decide whether two scores should be
/// compared. Leaderboard policy remains a game/backend responsibility.
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub struct RuntimeProvenance {
device_class: DeviceClass,
execution_model: ExecutionModel,
input_profile: InputProfile,
platform_family: PlatformFamily,
runtime_host: RuntimeHost,
}
impl RuntimeProvenance {
/// Creates an explicit runtime provenance declaration.
#[must_use]
pub const fn new(
device_class: DeviceClass,
execution_model: ExecutionModel,
input_profile: InputProfile,
platform_family: PlatformFamily,
runtime_host: RuntimeHost,
) -> Self {
return Self { device_class, execution_model, input_profile, platform_family, runtime_host };
}
/// Returns the physical device class.
#[must_use]
pub const fn device_class(self) -> DeviceClass {
return self.device_class;
}
/// Returns the execution model.
#[must_use]
pub const fn execution_model(self) -> ExecutionModel {
return self.execution_model;
}
/// Returns the primary input profile.
#[must_use]
pub const fn input_profile(self) -> InputProfile {
return self.input_profile;
}
/// Returns the broad platform family.
#[must_use]
pub const fn platform_family(self) -> PlatformFamily {
return self.platform_family;
}
/// Returns the runtime host container.
#[must_use]
pub const fn runtime_host(self) -> RuntimeHost {
return self.runtime_host;
}
}
#[cfg(test)]
#[path = "../unit_tests/environment.rs"]
mod tests;

View File

@@ -1,5 +1,5 @@
// file: crates/engines/engine-v1-platform-api/src/lib.rs
// version: 2
// version: 3
#![warn(missing_docs)]
#![deny(unreachable_pub)]
@@ -7,8 +7,21 @@
//! Platform service contracts shared by engine generation V1.
mod environment;
mod service;
/// Re-export of the physical device class used by runtime provenance.
pub use self::environment::DeviceClass;
/// Re-export of the native/WebAssembly execution model.
pub use self::environment::ExecutionModel;
/// Re-export of the primary gameplay input profile.
pub use self::environment::InputProfile;
/// Re-export of the broad runtime platform family.
pub use self::environment::PlatformFamily;
/// Re-export of the runtime host container.
pub use self::environment::RuntimeHost;
/// Re-export of descriptive runtime/session provenance.
pub use self::environment::RuntimeProvenance;
/// Re-export of optional monetization capability declarations.
pub use self::service::MonetizationCapabilities;
/// Re-export of the minimal platform service capability enumeration.

View File

@@ -0,0 +1,41 @@
// file: crates/engines/engine-v1-platform-api/unit_tests/environment.rs
// version: 1
#[test]
fn android_phone_touch_provenance_preserves_dimensions() {
game_logging_lib::with_test_tracing("android_phone_touch_provenance_preserves_dimensions", || {
let provenance = crate::RuntimeProvenance::new(
crate::DeviceClass::Phone,
crate::ExecutionModel::Native,
crate::InputProfile::Touch,
crate::PlatformFamily::Android,
crate::RuntimeHost::Native,
);
assert_eq!(provenance.device_class(), crate::DeviceClass::Phone);
assert_eq!(provenance.execution_model(), crate::ExecutionModel::Native);
assert_eq!(provenance.input_profile(), crate::InputProfile::Touch);
assert_eq!(provenance.platform_family(), crate::PlatformFamily::Android);
assert_eq!(provenance.runtime_host(), crate::RuntimeHost::Native);
});
}
#[test]
fn tauri_wasm_provenance_remains_distinct_from_native_desktop() {
game_logging_lib::with_test_tracing("tauri_wasm_provenance_remains_distinct_from_native_desktop", || {
let native = crate::RuntimeProvenance::new(
crate::DeviceClass::Desktop,
crate::ExecutionModel::Native,
crate::InputProfile::KeyboardMouse,
crate::PlatformFamily::Desktop,
crate::RuntimeHost::Native,
);
let tauri = crate::RuntimeProvenance::new(
crate::DeviceClass::Desktop,
crate::ExecutionModel::Wasm,
crate::InputProfile::KeyboardMouse,
crate::PlatformFamily::Desktop,
crate::RuntimeHost::TauriWebView,
);
assert_ne!(native, tauri);
});
}