1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
//! # Bothy
//!
//! Bothy is a local-first sync engine for applications that have no server of their own.
//! Each device keeps its data in a local SQLite database, and devices exchange immutable,
//! append-only files through the user's own cloud storage (Google Drive first).
//!
//! **Status: early development.** The local store, the merge rules, the file formats and the
//! sync engine work against a local or shared folder ([`remote::FolderRemote`]). The Google
//! Drive backend and the CLI are in progress at <https://github.com/bothy-sync/bothy>.
//!
//! ```
//! # #[tokio::main(flavor = "current_thread")]
//! # async fn main() -> bothy::Result<()> {
//! use std::sync::Arc;
//! use bothy::{Config, Database, remote::FolderRemote};
//! use serde_json::json;
//!
//! # let dir = tempfile::tempdir().unwrap();
//! # let (local_a, local_b, shared) = (dir.path().join("a.db"), dir.path().join("b.db"), dir.path().join("shared"));
//! let remote = Arc::new(FolderRemote::new(shared)?);
//!
//! // Device A creates the database and writes a note.
//! let a = Database::open(Config::new(local_a, "com.example.notes"), remote.clone()).await?;
//! let db_id = a.init().await?;
//! a.collection("notes")?.put("n1", json!({"title": "Hello"})).await?;
//! a.sync().await?;
//!
//! // Device B joins and receives it.
//! let b = Database::open(Config::new(local_b, "com.example.notes"), remote).await?;
//! b.join(db_id).await?;
//! let note = b.collection("notes")?.get("n1").await?.unwrap();
//! assert_eq!(note.to_json(), json!({"title": "Hello"}));
//! # Ok(())
//! # }
//! ```
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
/// Version of the on-remote file format written by this crate (`bothy_format` in
/// `manifest.json`). Draft: the format is not frozen until `SPEC.md` v1.
pub const FORMAT_VERSION: u16 = 1;