core: give consumers an in-memory store instead of a rusqlite dependency
The extraction left update.rs's tests reaching for rusqlite and uuid directly to build a Db — crates that now belong to the core alone, so clippy failed on unresolved imports. The Windows job had already compiled the whole installer, so this was only ever the test module. Adding rusqlite as a dev-dependency of the desktop crate would have fixed it and quietly undone part of the point: the desktop is not supposed to know what the store is made of. So the core exposes open_in_memory() instead, which is what the caller actually wanted, and the Android bindings will want the same thing when they get tests. uuid went the same way. It was generating unique scratch-directory names, which a process id plus a counter does without a dependency — process id separates concurrent cargo test runs, the counter separates tests within a run. The comment right above it already said nothing there was worth a new dependency. Verified the boundary holds in both directions afterwards: the desktop crate references none of rusqlite/uuid/chrono/reqwest/sha2, and the core references no tauri. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -28,6 +28,18 @@ pub fn open(path: &Path) -> rusqlite::Result<Db> {
|
||||
Ok(Db(Mutex::new(conn)))
|
||||
}
|
||||
|
||||
/// Open a migrated, in-memory store.
|
||||
///
|
||||
/// Exists so a CONSUMER can test against a real schema without taking a rusqlite
|
||||
/// dependency of its own just to build a `Db` — which is exactly what the desktop
|
||||
/// crate was doing before the core was extracted. The Android bindings will want the
|
||||
/// same thing.
|
||||
pub fn open_in_memory() -> rusqlite::Result<Db> {
|
||||
let conn = Connection::open_in_memory()?;
|
||||
schema::migrate(&conn)?;
|
||||
Ok(Db(Mutex::new(conn)))
|
||||
}
|
||||
|
||||
/// A one-line count summary of the store, for the startup log.
|
||||
pub fn summary(db: &Db) -> String {
|
||||
let conn = match db.0.lock() {
|
||||
|
||||
Reference in New Issue
Block a user