Cotton code
107 lines · 4.3 KB · RustRaw
//! CottonDB's CLIENT half — a client of a server, never a second writer.//!//! Step 3 of the Rust core (M6). What lives here is everything the Mac app does//! that is not the server and not the screen: the data directory and its//! refusals, the device key's use, which server this Mac talks to, and — as the//! later sub-steps land — the replica, the sync loop, the media drain and the//! ingest sources.//!//! It is its own crate rather than part of `cotton-server` because a client is//! not a server, and because Android will want exactly this code.//!//! Two rules hold across all of it, and both are older than this crate://! **pull always precedes push**, and **every fixture is synthetic** — a real//! number, name or message text anywhere in this tree is a hard failure.//! **What a PHONE gets is this crate with `--no-default-features`** (design//! P2): `data_dir`, `identity`, `layout`, `replica`, `media`, `seams`, `sync`,//! `connection` and `transport` — the client half a phone has always been.//! `ingest` and `ci` are the `host`//! feature, on by default, and every dependency only they need is `optional`//! in `Cargo.toml`. A module absent from a build cannot be reached by mistake,//! which is stronger than a stub that compiles and refuses at runtime./// The first copy of the file: the snapshot, streamed to disk, and the four/// corrections that make it this device's own.pub mod bootstrap;/// CI on a Mac: the bundled runner this machine runs jobs with, registered/// once and supervised on the backup's pattern.////// `host` only: a phone runs no jobs, has no login shell to capture and/// carries no helper to supervise.#[cfg(feature = "ci")]pub mod ci;pub mod connection;pub mod data_dir;pub mod dev_heal;pub mod moves;pub mod copy_keep;pub mod vault_keep;pub mod first_sync;pub mod unsent;pub mod unsent_heal;pub mod identity;/// Git on a Mac — the stat-only ladder that finds it, and the one credential/// this Mac installs for itself. `/usr/bin/git` is never executed.////// `host` only: a phone has no git, no keychain a checkout reads and no/// repository on disk, and the whole module is about a machine that clones.#[cfg(feature = "host")]pub mod git;/// Reading this machine's own Messages, call history, WhatsApp backup and/// Photos library. `host` only: an iPhone has no `~/Library` to read.#[cfg(feature = "ingest")]pub mod ingest;/// The joining half of pairing: this device presents its key, shows the six/// digits the server answered, and waits for somebody to type them.pub mod join;pub mod layout;pub mod media;/// The applier a message import writes through — the Mac's ingest sources and/// the phone's WhatsApp export alike. Feature-free on purpose.pub mod messages_import;pub mod replica;pub mod seams;/// The Stories table's shared pieces, on every build (the phone imports stories too).pub mod stories;/// The Code tool's client half on a phone: a session's terminal bytes.pub mod session_host;/// Starting a database on a device that is nobody's client yet./// Judge time, as this process holds it. On every device, a phone included: a/// replica takes its readings from the serving Mac's answers.pub mod judge;pub mod start;pub mod founding;pub mod sync;pub mod seal;pub mod transport;/// The vault's rows on a device: which devices wait to open it (every/// device's), and writing a secret onto THIS machine as a file (a machine that/// HOSTS, never a phone).pub mod vault;/// The fixtures every suite in this crate shares — synthetic, all of them.#[cfg(test)]mod test_support;pub use data_dir::{prepare_data_dir, DataDirRefusal, EarlyLog, PrepareDataDirResult, PrepareOps};pub use identity::{    identity_storage_for, load_or_mint_rehearsal_seed, DeviceIdentity, IdentityStorage,    REHEARSAL_MARK,};pub use layout::Layout;pub use replica::{    open_replica, open_replica_with, read_ingest_cursor, write_ingest_cursor, MigrationEvent, ReplicaJudge,    OpenReplicaInput, Replica, ReplicaError,};pub use seams::{Clock, Random, SystemClock, SystemRandom};pub use start::{    start_local, start_place, StartLocal, StartLocalError, StartPlace, StartedLocal, StartedPlace,    DATABASE_NAME_MAX,};#[cfg(all(feature = "host", unix))]pub mod file_keys;pub mod hardware_identity;pub mod whole_file;