pub struct BridgedEngineWrapper { /* private fields */ }Expand description
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.
Consuming crates expose a thin newtype around this via the
[uniffi_bridged_engine!] macro rather than hand-writing the facade.
All methods return anyhow::Result, which each crate maps onto its own
UniFFI error type via an impl From<anyhow::Error>.
Implementations§
Source§impl BridgedEngineWrapper
impl BridgedEngineWrapper
pub fn new(inner: Box<dyn SyncEngine + Send + Sync>) -> Self
Sourcepub fn last_sync(&self) -> Result<i64>
pub fn last_sync(&self) -> Result<i64>
The last sync time, in milliseconds. Desktop reads this to build the
collection URL for fetching incoming records. There is deliberately no
setter: the engine owns its last-sync time and advances it itself in
apply/set_uploaded.
Sourcepub fn reset_last_sync(&self) -> Result<()>
pub fn reset_last_sync(&self) -> Result<()>
Force a full re-download next sync by resetting the engine-owned
last_sync timestamp - lighter than a full reset.
Sourcepub fn sync_id(&self) -> Result<Option<String>>
pub fn sync_id(&self) -> Result<Option<String>>
The per-collection sync ID, derived from the engine’s sync association. (Bridged engines never maintain the “global” guid - that’s all managed by the consumer, ie, Desktop. They only care about the per-collection one.)
Sourcepub fn reset_sync_id(&self) -> Result<String>
pub fn reset_sync_id(&self) -> Result<String>
Resets the sync ID for this collection, returning the new ID. As a side
effect this resets all local Sync state, as in reset.
Sourcepub fn ensure_current_sync_id(&self, sync_id: &str) -> Result<String>
pub fn ensure_current_sync_id(&self, sync_id: &str) -> Result<String>
Ensures the locally stored sync ID matches sync_id; resets local Sync
state on a mismatch. Returns the assigned sync ID.
pub fn set_clients(&self, client_data: &str) -> Result<()>
pub fn sync_started(&self) -> Result<()>
Sourcepub fn store_incoming(&self, incoming: Vec<String>) -> Result<()>
pub fn store_incoming(&self, incoming: Vec<String>) -> Result<()>
Decode the JSON-encoded IncomingBsos that UniFFI passes to us, then
hand them to the wrapped engine.
Sourcepub fn apply(&self, server_modified_millis: i64) -> Result<Vec<String>>
pub fn apply(&self, server_modified_millis: i64) -> Result<Vec<String>>
Apply staged records and encode the outgoing OutgoingBsos back into
JSON for UniFFI.
server_modified_millis is the collection’s server last-modified time,
passed explicitly by Desktop (which has just stored it as the last sync
time before calling us). It’s forwarded to SyncEngine::apply exactly
as the native Rust client does, so reconciliation sees the real
timestamp.
Sourcepub fn set_uploaded(
&self,
server_modified_millis: i64,
ids: Vec<String>,
) -> Result<()>
pub fn set_uploaded( &self, server_modified_millis: i64, ids: Vec<String>, ) -> Result<()>
The uploaded ids always cross the UniFFI boundary as plain strings; we
convert them to Guid for the engine here.
pub fn sync_finished(&self) -> Result<()>
pub fn reset(&self) -> Result<()>
pub fn wipe(&self) -> Result<()>
Auto Trait Implementations§
impl Freeze for BridgedEngineWrapper
impl !RefUnwindSafe for BridgedEngineWrapper
impl Send for BridgedEngineWrapper
impl Sync for BridgedEngineWrapper
impl Unpin for BridgedEngineWrapper
impl !UnwindSafe for BridgedEngineWrapper
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
§impl<T, UT> HandleAlloc<UT> for T
impl<T, UT> HandleAlloc<UT> for T
§fn new_handle(value: Arc<T>) -> Handle
fn new_handle(value: Arc<T>) -> Handle
§unsafe fn clone_handle(handle: Handle) -> Handle
unsafe fn clone_handle(handle: Handle) -> Handle
§unsafe fn consume_handle(handle: Handle) -> Arc<T>
unsafe fn consume_handle(handle: Handle) -> Arc<T>
Arc<> Read more