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, ClientError,
49    ClientLimits, CommandEffects, CommitDelivery, CommitOperation, CommitOperationOutcome,
50    CommitOutcome, CommitOutcomeQuery, CommitOutcomeResolution, CommitOutcomeStatus,
51    ConflictRecord, CoverageSnapshot, DiagnosticLastChange, DiagnosticLastRound,
52    DiagnosticQueryFailure, DiagnosticRoundCounters, DiagnosticSubscription,
53    ExpectedDiagnosticSubscription, FetchedBlob, LocalDataPurgeInput, LocalDataPurgeResult,
54    LocalDataPurgeTarget, LocalDataRebootstrapInput, LocalDataRebootstrapResult, Mutation,
55    PresencePeer, QueryOwner, QueryReadFailure, QueryRow, QuerySnapshot, QueryValue,
56    RealtimePolicy, RealtimeState, RejectionRecord, ResolveCommitOutcomeInput, RetainedCommitRow,
57    RetainedUniqueConflict, RowState, SchemaFloor, SnapshotRead, SubscriptionCatchup,
58    SubscriptionStateView, SyncIntent, SyncOutcome, SyncReport, SyncStatusSnapshot, TableChange,
59    TimeBucketUnit, WindowBase, WindowChange, WindowCoverage, WindowState, WindowUnitRef,
60    CLIENT_DIAGNOSTICS_VERSION, MAX_DIAGNOSTIC_EXPECTED_SUBSCRIPTIONS,
61    MAX_DIAGNOSTIC_QUERY_FAILURES, REALTIME_LOST_CODE, REALTIME_UNAVAILABLE_CODE,
62};
63pub use client::{
64    FileQuerySnapshotReader, SnapshotReadRequest, SnapshotStatement, SyncClient,
65    SECURITY_PREFLIGHT_REQUIRED_CODE,
66};
67pub use schema::{compile_schema, parse_schema_json, ClientSchema};
68pub use transport::{BlobDownload, BlobUploadGrant, SegmentRequest, Transport, TransportError};
69
70// Re-export the SSP2 stream scanner (§8.7 round-response reassembly) so the
71// native transports (FFI + Tauri plugin) reach it through their existing
72// `syncular-client` dependency, without each adding a direct `ssp2` path dep.
73pub use realtime_round::{RealtimeRound, RoundInbound, REALTIME_TAG_DELTA, REALTIME_TAG_ROUND};
74pub use remote::{
75    PreparedRemoteCommit, RemoteBytes, RemoteClientError, RemoteCommandResult, RemoteCommitInput,
76    RemoteCommitResult, RemoteQueryResult, SyncRemoteClient,
77};
78pub use ssp2::{MessageStreamScanner, ScannedMessage};