Skip to main content

Module sync

Module sync 

Source
Expand description

Types and helpers shared between the hygg client and the sync server.

  • identity: the content-derived book identity (a stable cross-device id).
  • mode: the per-document sync policy (full / metadata / off).
  • autosync: the account/device-wide automatic-sync scope (which documents sync at all) plus the “looks like a book” heuristic.
  • proto: the JSON wire contract for the device + sync API, so the AGPL client and the Elastic-licensed server stay statically typed against one definition without either license crossing the boundary.

Re-exports§

pub use autosync::AutoSyncPolicy;
pub use autosync::BOOK_MIN_PDF_PAGES;
pub use autosync::BOOK_MIN_TEXT_LINES;
pub use autosync::looks_like_book;
pub use autosync::should_auto_sync;
pub use identity::book_id_for_file;
pub use identity::book_id_from_text;
pub use identity::content_sha256;
pub use mode::SyncMode;

Modules§

autosync
Which documents sync automatically — the account/device-wide sync scope, orthogonal to SyncMode (which decides what content syncs for a document that participates at all).
clock
Cross-device clock-skew correction for last-write-wins ordering.
headers
HTTP header names for device authentication, shared by the hygg client and server so both sides agree on the exact strings. Presenting a bearer token is no longer sufficient on its own: an authenticated request must also carry the account username and a stable per-machine id.
identity
Stable, content-derived identity for a document (“book”).
mode
How a document is synchronized. A single knob that exists at two levels: the server keeps an account-wide ceiling per document, and each client keeps a local clamp. The effective mode is the more restrictive of the two (SyncMode::most_restrictive), so a client may lower its own copy but never raise it above the server’s policy.
proto
The JSON wire contract between the hygg client (cli-text-reader / hygg) and the sync server (hygg-server). Every shape that crosses the network is defined here exactly once, so a change on either side is a compile error on the other: rename a field on the server and the client stops building until it is reconciled.