pub struct BridgedEngineWrapper { /* private fields */ }Expand description
Wraps a Box<dyn BridgedEngine> and centralizes the work every consuming
crate’s UniFFI-facing bridged engine needs to do: the JSON String <-> BSO
marshalling that crosses the FFI boundary, and 1:1 delegation to the wrapped
engine. Rather than each crate hand-writing this (it was ~100 identical lines
per crate), they expose a thin newtype around this via the
[uniffi_bridged_engine!] macro.
All methods return anyhow::Result, which each crate maps onto its own
UniFFI error type via an impl From<anyhow::Error>.
Note on the longer-term direction: this type, along with BridgedEngine,
BridgedEngineAdaptor and ApplyResults, only exists because we still
have two sync-engine traits. Once Desktop moves off explicit timestamp
handling to the get_collection_request model (see #2841) we can remove
BridgedEngine entirely, have Desktop consume SyncEngine directly, and
this wrapper collapses into a thin SyncEngine -> FFI shim (or goes away).
See the note in engine/mod.rs for the migration sequencing.
Implementations§
Source§impl BridgedEngineWrapper
impl BridgedEngineWrapper
pub fn new(inner: Box<dyn BridgedEngine>) -> Self
pub fn last_sync(&self) -> Result<i64>
pub fn set_last_sync(&self, last_sync: i64) -> Result<()>
pub fn sync_id(&self) -> Result<Option<String>>
pub fn reset_sync_id(&self) -> Result<String>
pub fn ensure_current_sync_id(&self, sync_id: &str) -> Result<String>
pub fn prepare_for_sync(&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) -> Result<Vec<String>>
pub fn apply(&self) -> Result<Vec<String>>
Apply staged records and encode the outgoing OutgoingBsos back into
JSON for UniFFI.
Sourcepub fn set_uploaded<G: Into<Guid>>(
&self,
server_modified_millis: i64,
ids: Vec<G>,
) -> Result<()>
pub fn set_uploaded<G: Into<Guid>>( &self, server_modified_millis: i64, ids: Vec<G>, ) -> Result<()>
Accepts anything that turns into a Guid, which reconciles the
per-crate id representation: logins hands us Vec<String>, while
tabs and webext-storage hand us Vec<sync_guid::Guid>. Both String
and Guid implement Into<Guid>.
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