Rust library
[dependencies]bothy = "0.4"use std::sync::Arc;use bothy::{AutoSync, Config, Database, remote::drive::DriveRemote};use serde_json::json;
let remote = Arc::new(DriveRemote::appdata(my_token_provider)?);let config = Config::new("notes.db", "com.example.notes").p2p(bothy::p2p::P2pConfig::new());let db = Database::open(config, remote).await?;db.init_or_join().await?;
let notes = db.collection("notes")?;notes.put("n1", json!({"title": "Hello"})).await?;let mut changes = db.subscribe();let sync = db.start_auto_sync(AutoSync::default());- Async and blocking: the async API needs a Tokio runtime.
bothy::blocking::Databaseis the same API for code without one; it runs its own small runtime. - Tokens:
my_token_providerimplementsbothy::auth::AccessTokenProvider(access token, and invalidation after Drive rejects one). Thebothy-oauthcrate has a ready one, with loopback and device code sign-in. - Remotes:
RemoteStoreis a small trait.FolderRemoteandDriveRemoteimplement it, and other backends can. - Features:
blocking,crypto,driveandp2pare on by default;test-utiladds a fault-injecting remote for tests.
The API reference is on docs.rs/bothy.