Skip to main content

Module core

Module core 

Source
Expand description

The transport-agnostic, Tauri-free CORE of the plugin.

Everything here is plain Rust with no dependency on the tauri crate, so it is unit-testable without a window or a mock runtime. The Tauri shell (see lib.rs) is a thin layer that owns one SyncularCore on a dedicated thread, forwards mutable commands and raw queries to it, and pumps drained events onto the syncular://event Tauri channel. The shell’s file-backed atomic snapshot sidecar is intentionally outside this mutable core and uses a separate read-only SQLite connection.

This mirrors the syncular-ffi Handle: one owned SyncClient, one owned HostTransport (native HTTP+WS via the native-transport feature), and an exact core-output event queue. The plugin is the THIRD consumer of the shared syncular-command router (after the conformance shim and the FFI core), so the command surface stays conformance-locked.

§Thread-safety, honestly

SyncClient is synchronous and NOT Sync — it owns a rusqlite connection. Exactly one thread owns the mutable core, and all mutable access arrives through a command mailbox (an mpsc channel). Tauri commands never touch that client directly. The background host loop (§8.4) runs on the same owner, so the mutable connection is never accessed concurrently. The shell may independently read the file database through SQLite’s snapshot model; it does not access this SyncClient.

Structs§

Event
One client-observable event (§8 realtime signals + §6 conflicts + §1.6 schema floor + §7.3 lease). JSON-able; delivered onto the Tauri channel. The same event vocabulary the FFI poll_event surfaces.
SyncularCore
The Tauri-free core: one client, its owned transport, explicit scheduling state, and the pending exact-event queue. Lives on ONE owning thread.