Module engine

Module engine 

Source
Expand description

This module is used by crates which need to implement a “sync engine”. At a high-level, a “sync engine” is code which knows how to take records from a sync server, apply and reconcile them with the local data, then provide records which should be uploaded to the server.

Note that the “sync engine” does not itself talk to the server, nor does it manage the state of the remote server, nor does it do any of the encryption/decryption - that is the responsbility of the “sync client”, as implemented in the [client] module (or in some cases, implemented externally)

SyncEngine is a trait which works on desktop and mobile. Engines implement it once and are driven two ways:

  • On mobile, via the sync manager. Engines manage their own last-sync time internally.
  • On Desktop, by the JS Sync framework via BridgedEngineWrapper and the uniffi_bridged_engine! macro.

Structs§

BridgedEngineWrapper
Adapts a SyncEngine to the method set that Desktop Firefox’s JS Sync framework drives (historically the mozIBridgedSyncEngine shape). Desktop owns the fetch loop, so unlike the native Rust sync client it reads and writes the engine’s last-sync time explicitly and manages sync IDs as opaque strings; this wrapper translates those calls onto the SyncEngine trait, and handles the JSON String <-> BSO marshalling that crosses the UniFFI boundary.
CollSyncIds
CollectionRequest

Enums§

EngineSyncAssociation
Defines how an engine is associated with a particular set of records on a sync storage server. It’s either disconnected, or believes it is connected with a specific set of GUIDs. If the server and the engine don’t agree on the exact GUIDs, the engine will assume something radical happened so it can’t believe anything it thinks it knows about the state of the server (ie, it will “reset” then do a full reconcile)
RequestOrder
SyncEngineId
The concrete SyncEngine implementations

Traits§

SyncEngine
A “sync engine” is a thing that knows how to sync. It’s often implemented by a “store” (which is the generic term responsible for all storage associated with a component, including storage required for sync.)