kovlet 0.1.0

Kovlet's portable sync client core: sign-in, sync, merge, outbox and files for Rust, Tauri, Swift and Kotlin apps
Documentation
//! # kovlet
//!
//! Kovlet's portable sync client core (ADR 0017): sign-in, the WebSocket
//! session and catch-up, the per-field LWW merge, the outbox and acks,
//! reconnects, files and the app-scoped spaces API, for Rust and Tauri apps
//! directly, and for Swift and Kotlin through UniFFI (`kovlet-ffi`).
//!
//! The app's database stays the source of truth: implement [`store::DataStore`]
//! (one method, `apply`) or use the built-in store, and the core keeps only
//! its bookkeeping (clocks, outbox, cursor) in a [`store::SyncStore`].
//!
//! ```no_run
//! # async fn demo() -> kovlet::Result<()> {
//! use kovlet::{col, Client, SignIn, Tables};
//! let kovlet = Client::builder("Todos").data_dir("/tmp/todos").build()?;
//! if !kovlet.signed_in() {
//!     kovlet.sign_in(SignIn::device(|c| println!("Open {} and enter {}", c.verification_uri, c.user_code))).await?;
//! }
//! let space_id = kovlet.spaces().find_or_create("Todos").await?.id;
//! let space = kovlet.open_builtin(&space_id, Tables::new().table("todos", [("title", col::string()), ("done", col::boolean())]))?;
//! space.write("todos").upsert("t1", serde_json::json!({ "title": "Buy milk", "done": false }))?;
//! let mut status = kovlet.watch_status();
//! while status.changed().await.is_ok() { println!("{:?}", status.borrow().state); }
//! # Ok(()) }
//! ```

mod api;
pub mod auth;
mod client;
mod end_users;
pub mod engine;
pub mod error;
mod files;
pub mod hlc;
mod mirror;
pub mod protocol;
pub mod query;
pub mod schema;
mod space;
pub mod spaces;
pub mod store;
pub mod testing;
pub mod transport;

pub use auth::key::{DeviceKey, KeyProvider, SoftwareKey, SoftwareKeyProvider};
pub use auth::secrets::{FileSecretStore, MemorySecretStore, SecretStore};
pub use auth::{DeviceCode, EndUser, EndUserOAuthRequest, EndUserSession, EndUserSignIn, PkceRequest, Session, SignIn};
pub use client::{Client, ClientBuilder, SpaceStore, Status, SyncSummary, DEFAULT_API_URL, DEFAULT_CONSOLE_URL};
pub use end_users::{EndUserConfig, EndUserProvider, EndUsers};
pub use engine::{Blocked, Event, SpaceStatus, SubscriptionStatus, SyncState};
pub use error::{Error, Result};
pub use mirror::{Mirror, MirrorStatus};
pub use query::QueryResult;
pub use schema::{col, Tables};
pub use space::{Files, LiveQuery, LocalWrite, Space, Subscription, TableReader, TableWriter, Transaction};
pub use store::{Change, ChangeBatch, DataStore, Origin, Row};

/// The SQLite store (feature `sqlite`).
#[cfg(feature = "sqlite")]
pub mod sqlite {
    pub use crate::store::sqlite::{ApplyBatchFn, ApplyFn, LendFn, SqliteStore, SCHEMA};
    pub use rusqlite;
}

/// The serde_json re-export, for `json!` in app code.
pub use serde_json;