fix(workspace): add derives/docs per code review, remove unused thiserror from solitaire_sync
This commit is contained in:
Generated
-1
@@ -6815,7 +6815,6 @@ dependencies = [
|
|||||||
"chrono",
|
"chrono",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"thiserror 1.0.69",
|
|
||||||
"uuid",
|
"uuid",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -7,6 +7,8 @@ use thiserror::Error;
|
|||||||
pub enum SyncError {
|
pub enum SyncError {
|
||||||
#[error("unsupported platform for this sync backend")]
|
#[error("unsupported platform for this sync backend")]
|
||||||
UnsupportedPlatform,
|
UnsupportedPlatform,
|
||||||
|
// TODO: Replace String with concrete source error types (e.g. reqwest::Error,
|
||||||
|
// serde_json::Error) when real implementations are added in Phase 8.
|
||||||
#[error("network error: {0}")]
|
#[error("network error: {0}")]
|
||||||
Network(String),
|
Network(String),
|
||||||
#[error("authentication error: {0}")]
|
#[error("authentication error: {0}")]
|
||||||
@@ -19,9 +21,13 @@ pub enum SyncError {
|
|||||||
/// methods — it never matches on a backend enum variant.
|
/// methods — it never matches on a backend enum variant.
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
pub trait SyncProvider: Send + Sync {
|
pub trait SyncProvider: Send + Sync {
|
||||||
|
/// Fetch the remote sync payload. Returns the latest server state for merging.
|
||||||
async fn pull(&self) -> Result<SyncPayload, SyncError>;
|
async fn pull(&self) -> Result<SyncPayload, SyncError>;
|
||||||
|
/// Push the local payload to the backend. Returns the merged server response.
|
||||||
async fn push(&self, payload: &SyncPayload) -> Result<SyncResponse, SyncError>;
|
async fn push(&self, payload: &SyncPayload) -> Result<SyncResponse, SyncError>;
|
||||||
|
/// Human-readable name of this backend, used in settings UI and logs.
|
||||||
fn backend_name(&self) -> &'static str;
|
fn backend_name(&self) -> &'static str;
|
||||||
|
/// Returns true if the user is currently authenticated with this backend.
|
||||||
fn is_authenticated(&self) -> bool;
|
fn is_authenticated(&self) -> bool;
|
||||||
/// Mirror an achievement unlock to this backend (no-op for most backends).
|
/// Mirror an achievement unlock to this backend (no-op for most backends).
|
||||||
async fn mirror_achievement(&self, _id: &str) -> Result<(), SyncError> {
|
async fn mirror_achievement(&self, _id: &str) -> Result<(), SyncError> {
|
||||||
|
|||||||
@@ -2,11 +2,14 @@ use async_trait::async_trait;
|
|||||||
use solitaire_data::{SyncError, SyncProvider};
|
use solitaire_data::{SyncError, SyncProvider};
|
||||||
use solitaire_sync::{SyncPayload, SyncResponse};
|
use solitaire_sync::{SyncPayload, SyncResponse};
|
||||||
|
|
||||||
/// Desktop/iOS stub — always returns UnsupportedPlatform.
|
/// Google Play Games Services sync client — desktop/iOS stub.
|
||||||
/// Real implementation lives in android.rs (Phase: Android).
|
///
|
||||||
|
/// Always returns [`SyncError::UnsupportedPlatform`]. The real JNI implementation
|
||||||
|
/// lives in `android.rs` and is compiled only on Android (Phase: Android).
|
||||||
pub struct GpgsClient;
|
pub struct GpgsClient;
|
||||||
|
|
||||||
impl GpgsClient {
|
impl GpgsClient {
|
||||||
|
/// Creates a new `GpgsClient` stub. No-op on non-Android platforms.
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Self
|
Self
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,4 +8,3 @@ serde = { workspace = true }
|
|||||||
serde_json = { workspace = true }
|
serde_json = { workspace = true }
|
||||||
uuid = { workspace = true }
|
uuid = { workspace = true }
|
||||||
chrono = { workspace = true }
|
chrono = { workspace = true }
|
||||||
thiserror = { workspace = true }
|
|
||||||
|
|||||||
@@ -4,14 +4,14 @@ use uuid::Uuid;
|
|||||||
|
|
||||||
/// Payload sent from client to server (and returned after server merge).
|
/// Payload sent from client to server (and returned after server merge).
|
||||||
/// Full fields are added in Phase 8 (Sync System).
|
/// Full fields are added in Phase 8 (Sync System).
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||||
pub struct SyncPayload {
|
pub struct SyncPayload {
|
||||||
pub user_id: Uuid,
|
pub user_id: Uuid,
|
||||||
pub last_modified: DateTime<Utc>,
|
pub last_modified: DateTime<Utc>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Response returned by the sync server after merging.
|
/// Response returned by the sync server after merging.
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||||
pub struct SyncResponse {
|
pub struct SyncResponse {
|
||||||
pub server_time: DateTime<Utc>,
|
pub server_time: DateTime<Utc>,
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user