Common/Synchronization/
SynchronizationProvider.rs

1//! # SynchronizationProvider Trait
2//!
3//! Defines the abstract service trait for synchronizing user data with a
4//! remote service.
5
6use async_trait::async_trait;
7use serde_json::Value;
8
9use crate::{Environment::Environment::Environment, Error::CommonError::CommonError};
10
11/// An abstract service contract for an environment component that can
12/// synchronize user data (settings, keybindings, extensions, snippets, etc.)
13/// with a remote storage backend, such as a cloud service.
14#[async_trait]
15pub trait SynchronizationProvider: Environment + Send + Sync {
16	/// Pushes the current local user data state to the remote sync service.
17	///
18	/// # Parameters
19	/// * `UserData`: A `serde_json::Value` containing the complete user data to
20	///   be synchronized.
21	async fn PushUserData(&self, UserData:Value) -> Result<(), CommonError>;
22
23	/// Pulls the latest user data state from the remote sync service.
24	///
25	/// # Returns
26	/// A `Result` containing a `serde_json::Value` with the complete user
27	/// data from the remote service, which can then be merged with and applied
28	/// to the local configuration.
29	async fn PullUserData(&self) -> Result<Value, CommonError>;
30}