Expand description
Mutation backend abstraction.
This module defines MutationBackend, a trait that abstracts every Things 3
mutation operation behind a single interface. The MCP server holds an
Arc<dyn MutationBackend> and dispatches all writes through it. This unblocks
issue #120’s migration from direct SQLite writes (which CulturedCode warns can
corrupt the user’s database) to AppleScript-based mutations.
Two implementations are planned:
SqlxBackend— wraps the existing direct-DB writes oncrate::ThingsDatabase. Today’s behavior; useful for offline tests and CI.AppleScriptBackend— to be added in #124. The default in production after #125.
§Why #[async_trait] instead of native async fn in traits
The trait must be object-safe so the server can hold Arc<dyn MutationBackend>
and choose between backends at runtime. Native async-fn-in-trait (Rust 1.75+)
requires #[trait_variant] shims for dyn dispatch and produces unnameable
opaque return types — too much friction for marginal benefit. #[async_trait]
boxes the future, which is exactly what dyn needs.
Structs§
Traits§
- Mutation
Backend - Abstraction over every Things 3 mutation operation exposed as an MCP tool.