actr_platform_traits/lib.rs
1//! # actr-platform-traits
2//!
3//! Platform abstraction traits for Actor-RTC.
4//!
5//! This crate defines the boundary between platform-agnostic orchestration logic
6//! (Hyper, ActrNode runtime) and platform-specific implementations (native, web).
7//!
8//! ## Traits
9//!
10//! - [`KvStore`] — key-value storage (SQLite on native, IndexedDB on web)
11//! - [`CryptoProvider`] — cryptographic primitives (ed25519-dalek on native, Web Crypto on web)
12//! - [`PlatformProvider`] — composite provider grouping all platform services
13
14pub mod crypto;
15pub mod platform;
16pub mod storage;
17
18pub use crypto::CryptoProvider;
19pub use platform::PlatformProvider;
20pub use storage::{KvOp, KvStore, KvStoreClone};
21
22use thiserror::Error;
23
24/// Unified error type for platform operations
25#[derive(Debug, Error)]
26pub enum PlatformError {
27 /// Storage operation failed
28 #[error("storage error: {0}")]
29 Storage(String),
30
31 /// Cryptographic operation failed
32 #[error("crypto error: {0}")]
33 Crypto(String),
34
35 /// I/O error
36 #[error("io error: {0}")]
37 Io(String),
38
39 /// Other error
40 #[error("{0}")]
41 Other(String),
42}
43
44impl From<std::io::Error> for PlatformError {
45 fn from(e: std::io::Error) -> Self {
46 PlatformError::Io(e.to_string())
47 }
48}