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:
@@ -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>>;
|
||||
}
|
||||
Reference in New Issue
Block a user