pub struct CloudSaveClient {
pub provider: CloudProvider,
pub user_id: String,
pub state: CloudSyncState,
pub stats: CloudSaveStats,
pub metadata: CloudMetadata,
pub conflict_resolution: ConflictResolution,
/* private fields */
}Expand description
Manages upload/download queue, conflict detection, retry with exponential backoff (3 attempts), and a concurrent upload limit of 2.
Fields§
§provider: CloudProvider§user_id: String§state: CloudSyncState§stats: CloudSaveStats§metadata: CloudMetadata§conflict_resolution: ConflictResolutionImplementations§
Source§impl CloudSaveClient
impl CloudSaveClient
pub fn new(provider: CloudProvider, user_id: impl Into<String>) -> Self
pub fn set_online(&mut self, online: bool)
Sourcepub fn upload_slot(
&mut self,
slot_id: u32,
data: Vec<u8>,
timestamp: u64,
) -> Result<(), String>
pub fn upload_slot( &mut self, slot_id: u32, data: Vec<u8>, timestamp: u64, ) -> Result<(), String>
Upload a slot to the (simulated) remote store.
Sourcepub fn download_slot(&mut self, slot_id: u32) -> Result<Vec<u8>, String>
pub fn download_slot(&mut self, slot_id: u32) -> Result<Vec<u8>, String>
Download a slot from the (simulated) remote store.
Sourcepub fn resolve_conflict(
&mut self,
slot_id: u32,
local_data: Vec<u8>,
local_timestamp: u64,
resolution: ConflictResolution,
) -> Result<Vec<u8>, String>
pub fn resolve_conflict( &mut self, slot_id: u32, local_data: Vec<u8>, local_timestamp: u64, resolution: ConflictResolution, ) -> Result<Vec<u8>, String>
Detect and resolve conflicts for a slot.
A conflict exists when local and remote checksums differ.
Sourcepub fn sync_all(&mut self, timestamp: u64) -> Result<(), String>
pub fn sync_all(&mut self, timestamp: u64) -> Result<(), String>
Sync all locally known slots to the remote.
pub fn offline_queue(&self) -> &OfflineQueue
pub fn backup_manager(&self) -> &BackupManager
pub fn backup_manager_mut(&mut self) -> &mut BackupManager
Auto Trait Implementations§
impl Freeze for CloudSaveClient
impl RefUnwindSafe for CloudSaveClient
impl Send for CloudSaveClient
impl Sync for CloudSaveClient
impl Unpin for CloudSaveClient
impl UnsafeUnpin for CloudSaveClient
impl UnwindSafe for CloudSaveClient
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.