diff options
| author | Valentin Popov <valentin@popov.link> | 2026-06-22 12:12:27 +0300 |
|---|---|---|
| committer | Valentin Popov <valentin@popov.link> | 2026-06-22 12:13:32 +0300 |
| commit | d0bdbaa1ed76dfbf3211bb43eee48c49cc4fd448 (patch) | |
| tree | a0bd35c3940be62a5b5de1acc2366af377ffd181 /crates/fparkan-platform | |
| parent | 7416fdc7e9a48837fff5056e6dc8d0774e90964b (diff) | |
| download | fparkan-d0bdbaa1ed76dfbf3211bb43eee48c49cc4fd448.tar.xz fparkan-d0bdbaa1ed76dfbf3211bb43eee48c49cc4fd448.zip | |
feat: implement FParkan architecture foundation
Add the modular fparkan workspace, domain crates, adapters, apps, xtask policy/CI, acceptance evidence, and licensed corpus gates for the macOS-focused roadmap foundation.
Diffstat (limited to 'crates/fparkan-platform')
| -rw-r--r-- | crates/fparkan-platform/Cargo.toml | 11 | ||||
| -rw-r--r-- | crates/fparkan-platform/src/lib.rs | 93 |
2 files changed, 104 insertions, 0 deletions
diff --git a/crates/fparkan-platform/Cargo.toml b/crates/fparkan-platform/Cargo.toml new file mode 100644 index 0000000..dc103f2 --- /dev/null +++ b/crates/fparkan-platform/Cargo.toml @@ -0,0 +1,11 @@ +[package] +name = "fparkan-platform" +version.workspace = true +edition.workspace = true +license.workspace = true +repository.workspace = true + +[dependencies] + +[lints] +workspace = true diff --git a/crates/fparkan-platform/src/lib.rs b/crates/fparkan-platform/src/lib.rs new file mode 100644 index 0000000..cfa021b --- /dev/null +++ b/crates/fparkan-platform/src/lib.rs @@ -0,0 +1,93 @@ +#![forbid(unsafe_code)] +//! Platform ports for clocks, input, events, windows, and graphics requests. + +/// Monotonic instant. +#[derive(Clone, Copy, Debug, Eq, Ord, PartialEq, PartialOrd)] +pub struct MonotonicInstant(pub u64); + +/// Monotonic clock. +pub trait MonotonicClock { + /// Current instant. + fn now(&self) -> MonotonicInstant; +} + +/// Platform event. +#[derive(Clone, Debug, Eq, PartialEq)] +pub enum PlatformEvent { + /// Quit requested. + Quit, +} + +/// Platform error. +#[derive(Debug)] +pub enum PlatformError { + /// Backend failed. + Backend, +} + +impl std::fmt::Display for PlatformError { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "{self:?}") + } +} + +impl std::error::Error for PlatformError {} + +/// Event source. +pub trait EventSource { + /// Polls events. + /// + /// # Errors + /// + /// Returns [`PlatformError`] when the backend cannot collect events. + fn poll(&mut self, out: &mut Vec<PlatformEvent>) -> Result<(), PlatformError>; +} + +/// Physical size. +#[derive(Clone, Copy, Debug, Eq, PartialEq)] +pub struct PhysicalSize { + /// Width. + pub width: u32, + /// Height. + pub height: u32, +} + +/// Window port. +pub trait WindowPort { + /// Drawable size. + fn drawable_size(&self) -> PhysicalSize; + /// Presents. + /// + /// # Errors + /// + /// Returns [`PlatformError`] when the backend cannot present the current + /// frame. + fn present(&mut self) -> Result<(), PlatformError>; +} + +/// Graphics profile. +#[derive(Clone, Copy, Debug, Eq, PartialEq)] +pub enum GraphicsProfile { + /// Desktop core. + DesktopCore, + /// Embedded profile. + Embedded, +} + +/// Version. +#[derive(Clone, Copy, Debug, Eq, PartialEq)] +pub struct Version { + /// Major. + pub major: u8, + /// Minor. + pub minor: u8, +} + +/// Graphics context request. +#[derive(Clone, Copy, Debug, Eq, PartialEq)] +pub struct GraphicsContextRequest { + /// Profile. + pub profile: GraphicsProfile, + /// Version. + pub version: Version, +} |
