BridgedEngineWrapper

Struct BridgedEngineWrapper 

Source
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

Source

pub fn new(inner: Box<dyn SyncEngine + Send + Sync>) -> Self

Source

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.

Source

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.

Source

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.)

Source

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.

Source

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.

Source

pub fn set_clients(&self, client_data: &str) -> Result<()>

Source

pub fn sync_started(&self) -> Result<()>

Source

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.

Source

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.

Source

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.

Source

pub fn sync_finished(&self) -> Result<()>

Source

pub fn reset(&self) -> Result<()>

Source

pub fn wipe(&self) -> Result<()>

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.

§

impl<T, UT> HandleAlloc<UT> for T
where T: Send + Sync,

§

fn new_handle(value: Arc<T>) -> Handle

Create a new handle for an Arc value Read more
§

unsafe fn clone_handle(handle: Handle) -> Handle

Clone a handle Read more
§

unsafe fn consume_handle(handle: Handle) -> Arc<T>

Consume a handle, getting back the initial Arc<> Read more
§

unsafe fn get_arc(handle: Handle) -> Arc<Self>

Get a clone of the Arc<> using a “borrowed” handle. Read more
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
§

impl<T> ErasedDestructor for T
where T: 'static,