feat(engine): add platform abstraction trait skeleton (closes #47)

Adds solitaire_engine::platform::{StorageBackend, PlatformTime} traits.
No implementations yet — native and WASM impls follow in #48.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
funman300
2026-05-27 16:58:42 -07:00
parent 3885b334ec
commit 86bafdd679
4 changed files with 43 additions and 0 deletions
+19
View File
@@ -0,0 +1,19 @@
use std::io;
/// Abstracts platform-specific key-value / file storage.
///
/// Native: backed by the filesystem (via `solitaire_data`).
/// WASM: backed by `localStorage` / `sessionStorage`.
pub trait StorageBackend: Send + Sync + 'static {
/// Read bytes for the given key. Returns `None` if the key does not exist.
fn read(&self, key: &str) -> io::Result<Option<Vec<u8>>>;
/// Write bytes for the given key atomically.
fn write(&self, key: &str, data: &[u8]) -> io::Result<()>;
/// Delete a key. No-op if the key does not exist.
fn delete(&self, key: &str) -> io::Result<()>;
/// List all known keys (for migration / debug purposes).
fn keys(&self) -> io::Result<Vec<String>>;
}