Skip to main content

syncular_client/
lib.rs

1//! # syncular-client — Syncular v2 Rust client core (POC stage 2)
2//!
3//! A clean-room client implementation of the SPEC.md client-behavior
4//! contract on rusqlite local storage, consuming the committed `ssp2`
5//! codec as its wire layer. Built without reading the v1 Rust tree or the
6//! v2 TypeScript client — the conformance catalog (packages/conformance)
7//! is the proof that both cores implement one written protocol.
8//!
9//! Blocking hosts drive `sync()` / `sync_until_idle()`. Mailbox hosts prepare
10//! a round on the owner, run `PreparedSyncRound::exchange` on an I/O executor,
11//! and apply the result on the owner. An upload continuation repeats that
12//! exchange/apply cycle before the captured metadata request. The owner can
13//! serve local commands throughout; it queues inbound realtime traffic until
14//! the round completes. Scheduling is host policy (§8.4).
15
16pub mod api;
17#[cfg(feature = "bench-internals")]
18mod bench;
19pub mod client;
20/// §5.10.5 native CRDT helpers (the `crdt-yjs` feature) — the Rust face of the
21/// Yjs binding, mirroring `@syncular/crdt-yjs`. Off by default (dependency-lean).
22#[cfg(feature = "crdt-yjs")]
23pub mod crdt;
24/// Shared blocking HTTP/WebSocket host transport for Rust-backed bindings.
25/// The network stack is feature-gated; its no-network shape remains available
26/// in dependency-lean builds so host code needs only one transport type.
27pub mod native_transport;
28mod progress;
29mod round;
30pub use progress::{
31    ProgressObserver, ProgressPhase, ProgressState, ProgressSubscription, SyncProgress,
32    SyncProgressListener,
33};
34pub use round::{AppliedSyncRound, CompletedSyncRound, PreparedSyncRound};
35/// RFC 0005 previous-version context: the persisted schema descriptor, the
36/// bounded capture, and the sibling container FILE beside the replica.
37pub mod previous_version;
38pub mod query_guard;
39pub mod realtime_round;
40pub mod remote;
41pub mod schema;
42pub mod transport;
43pub mod values;
44
45pub use api::{
46    creation_time_bucket, last, AuthorityReadDeclaration, ClientChangeBatch, ClientDiagnosticsHost,
47    ClientDiagnosticsLease, ClientDiagnosticsReplica, ClientDiagnosticsRequest,
48    ClientDiagnosticsSchema, ClientDiagnosticsSnapshot, ClientDiagnosticsStorage, ClientLimits,
49    CommandEffects, CommitOperation, CommitOperationOutcome, CommitOutcome, CommitOutcomeQuery,
50    CommitOutcomeResolution, CommitOutcomeStatus, ConflictRecord, CoverageSnapshot,
51    DiagnosticLastChange, DiagnosticLastRound, DiagnosticQueryFailure, DiagnosticRoundCounters,
52    DiagnosticSubscription, ExpectedDiagnosticSubscription, FetchedBlob, LocalDataPurgeInput,
53    LocalDataPurgeResult, LocalDataPurgeTarget, LocalDataRebootstrapInput,
54    LocalDataRebootstrapResult, Mutation, PresencePeer, QueryOwner, QueryReadFailure, QueryRow,
55    QuerySnapshot, QueryValue, RealtimePolicy, RealtimeState, RejectionRecord,
56    ResolveCommitOutcomeInput, RetainedCommitRow, RetainedUniqueConflict, RowState, SchemaFloor,
57    SubscriptionStateView, SyncIntent, SyncOutcome, SyncReport, SyncStatusSnapshot, TableChange,
58    TimeBucketUnit, WindowBase, WindowChange, WindowCoverage, WindowState, WindowUnitRef,
59    CLIENT_DIAGNOSTICS_VERSION, MAX_DIAGNOSTIC_EXPECTED_SUBSCRIPTIONS,
60    MAX_DIAGNOSTIC_QUERY_FAILURES, REALTIME_LOST_CODE, REALTIME_UNAVAILABLE_CODE,
61};
62pub use client::{FileQuerySnapshotReader, SyncClient, SECURITY_PREFLIGHT_REQUIRED_CODE};
63pub use schema::{compile_schema, parse_schema_json, ClientSchema};
64pub use transport::{BlobDownload, BlobUploadGrant, SegmentRequest, Transport, TransportError};
65
66// Re-export the SSP2 stream scanner (§8.7 round-response reassembly) so the
67// native transports (FFI + Tauri plugin) reach it through their existing
68// `syncular-client` dependency, without each adding a direct `ssp2` path dep.
69pub use realtime_round::{RealtimeRound, RoundInbound, REALTIME_TAG_DELTA, REALTIME_TAG_ROUND};
70pub use remote::{
71    PreparedRemoteCommit, RemoteBytes, RemoteClientError, RemoteCommandResult, RemoteCommitInput,
72    RemoteCommitResult, RemoteQueryResult, SyncRemoteClient,
73};
74pub use ssp2::{MessageStreamScanner, ScannedMessage};