Use powersync_sqlite_nostd for internal queries#14
Conversation
rkistner
left a comment
There was a problem hiding this comment.
I didn't follow the specific implementation, but it makes sense to have rusqlite be an optional dependency.
One question: Would it make sense to have a separate crate for rusqlite support, instead of having it be an optional feature? That's how we're structuring things in some other places (e.g. drizzle/kysely support in the JS SDKs), but I'm not familiar enough with how these kinds of optional dependencies are typically structured in Rust crates.
At least from what I've seen, it looks like these integrations are commonly part of the main crate with optional features to disable them (for example, virtually every crate defining data structures has an optional Another thing we have in Rust is crate-level visibility, so different integrations could share internals that aren't part of a public API for which we'd have to maintain backwards compatibility. A downside is that if we need to make a breaking change affecting only one integration, we'd still have to make it a major upgrade on the crate which is annoying for everyone. FWIW we already have some optional features (the tokio and smol-rs integrations are both optional features instead of additional crates). That model feels natural in Rust, but I can also see how larger integrations like ORMs make more sense as standalone crates. I've contemplated adding the tauri integration as an optional feature instead of a separate crate. But in the end, a separate crate was a better call since we want to maintain that with the JS SDK. |
We heavily rely on the
rusqlitecrate in our public APIs (e.g. as aDereftarget for leased connections, or to auto-watchrusqlite::Statements). It's a nice crate providing safe and ergonomic bindings to SQLite, and it makes sense to center parts of our Rust APIs around that.However, we're also exploring using the Rust SDK in scenarios where
rusqlitemight be less helpful:libsqlite3-sys, which either adds a link dependency on-lsqlite3or bundles SQLite with the app. Neither option is great for Swift.rusqlitedoesn't supportnostdtargets. We don't currently support them either, butrusqliteis one of the bigger blockers towards that and running PowerSync on embedded targets would be kind of neat.So, this makes
rusqlitean optional but default dependency. Internally, this adds theSqliteConnectionstruct which wraps arusqlite::Connectionif that feature is enabled or aManagedConnectionotherwise. Either way, internal statements are run by obtaining a*mut sqlite3pointer and then usingpowersync_sqlite_nostdAPIs.