Skip to main content

SyncCoordinator

Struct SyncCoordinator 

Source
pub struct SyncCoordinator { /* private fields */ }
Expand description

Sync coordinator for managing multi-device state

Implementations§

Source§

impl SyncCoordinator

Source

pub fn new(device_id: DeviceId) -> Self

Creates a new sync coordinator

§Arguments
  • device_id - This device’s identifier
Source

pub fn device_id(&self) -> &DeviceId

Gets this device’s ID

Source

pub fn register_device(&self, device_id: DeviceId) -> SyncResult<()>

Registers a new device

§Arguments
  • device_id - The device to register
Source

pub fn unregister_device(&self, device_id: &DeviceId) -> SyncResult<()>

Unregisters a device

§Arguments
  • device_id - The device to unregister
Source

pub fn update_device_status( &self, device_id: &DeviceId, status: DeviceStatus, ) -> SyncResult<()>

Updates device status

§Arguments
  • device_id - The device to update
  • status - The new status
Source

pub fn get_device(&self, device_id: &DeviceId) -> Option<DeviceMetadata>

Gets device metadata

§Arguments
  • device_id - The device to query
Source

pub fn list_devices(&self) -> Vec<DeviceMetadata>

Lists all registered devices

Source

pub fn list_online_devices(&self) -> Vec<DeviceMetadata>

Lists all online devices

Source

pub fn cleanup_stale_devices(&self, timeout_secs: u64) -> usize

Checks for stale devices and marks them offline

§Arguments
  • timeout_secs - Timeout in seconds
Source

pub fn start_sync_session( &self, target_device: DeviceId, ) -> SyncResult<SyncSession>

Starts a sync session between two devices

§Arguments
  • target_device - The device to sync with
Source

pub fn complete_sync_session(&self, session_id: &str) -> SyncResult<()>

Completes a sync session

§Arguments
  • session_id - The session to complete
Source

pub fn active_sessions(&self) -> Vec<SyncSession>

Gets active sync sessions

Source

pub fn completed_sessions(&self) -> Vec<SyncSession>

Gets completed sync sessions

Source

pub fn sync_crdt<T: Crdt>( &self, local_crdt: &mut T, remote_crdt: &T, ) -> SyncResult<()>

Synchronizes CRDT state with another device

§Arguments
  • local_crdt - Local CRDT state
  • remote_crdt - Remote CRDT state
Source

pub fn create_delta(&self, base: &[u8], target: &[u8]) -> SyncResult<Delta>

Creates a delta between two data versions

§Arguments
  • base - Base data
  • target - Target data
Source

pub fn apply_delta(&self, base: &[u8], delta: &Delta) -> SyncResult<Vec<u8>>

Applies a delta to base data

§Arguments
  • base - Base data
  • delta - Delta to apply
Source

pub fn update_device_clock( &self, device_id: &DeviceId, clock: VectorClock, ) -> SyncResult<()>

Updates device clock

§Arguments
  • device_id - Device to update
  • clock - New clock value
Source

pub fn compare_device_clocks( &self, device1: &DeviceId, device2: &DeviceId, ) -> SyncResult<ClockOrdering>

Compares clocks between two devices

§Arguments
  • device1 - First device
  • device2 - Second device

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.