pub struct SyncularCore { /* private fields */ }Expand description
The Tauri-free core: one client, its owned transport, the derived-event diff state, and the pending event queue. Lives on ONE owning thread.
Implementations§
Source§impl SyncularCore
impl SyncularCore
Sourcepub fn new(config: &Value) -> Result<Self, String>
pub fn new(config: &Value) -> Result<Self, String>
Build a core from the plugin config JSON (baseUrl, headers, …). A
baseUrl under the native-transport feature owns a real HTTP+WS
transport; without it the core is client-local only (tests, offline).
Sourcepub fn command(&mut self, command: &Value) -> Value
pub fn command(&mut self, command: &Value) -> Value
Run one JSON command ({"method","params"}) through the shared router,
then drain inbound realtime traffic and derive events. Returns the
driver-protocol {"result"|"error"} reply.
Sourcepub fn query(&mut self, sql: &str, params: Value) -> Value
pub fn query(&mut self, sql: &str, params: Value) -> Value
The syncular_query fast path: arbitrary read-only SQL over the local
database. Routed through the same query command so there is one
implementation (the router owns it); this wrapper spares the JS bridge
from wrapping the method/params envelope for the hot live-query path.
Sourcepub fn sync_needed(&self) -> bool
pub fn sync_needed(&self) -> bool
True when the core wants a sync round (§8.4 coalesced signal). The host
loop polls this to decide whether to run syncUntilIdle.
Sourcepub fn sync_until_idle(&mut self) -> Value
pub fn sync_until_idle(&mut self) -> Value
Run one syncUntilIdle round for the background host loop, deriving
events afterwards. A no-op (empty reply) before create.
Sourcepub fn drain_events(&mut self) -> Vec<Event>
pub fn drain_events(&mut self) -> Vec<Event>
Drain every event queued since the last call (the host thread pushes
them onto the Tauri channel). Mirrors the FFI poll_event, batched.
Sourcepub fn set_headers(&mut self, headers: Vec<(String, String)>)
pub fn set_headers(&mut self, headers: Vec<(String, String)>)
Replace the transport’s request headers (RFC 0002 §2.3 — rotating
auth without tearing the plugin down). See
HostTransport::set_headers for the HTTP/WS pickup semantics.