Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rust bindings #79

Open
penberg opened this issue Nov 25, 2022 · 1 comment
Open

Rust bindings #79

penberg opened this issue Nov 25, 2022 · 1 comment
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@penberg
Copy link
Collaborator

penberg commented Nov 25, 2022

It would be great to have either a feature flag in the sqlite crate https://crates.io/crates/sqlite or a separate libsql crate for easy consumption of the library.

@penberg penberg added enhancement New feature or request help wanted Extra attention is needed labels Nov 25, 2022
@psarna
Copy link
Collaborator

psarna commented Nov 25, 2022

If migrating to https://crates.io/crates/rusqlite isn't out of the question, it allows consuming a custom sqlite library. It's already used like that in libsql tests: https://github.com/libsql/libsql/blob/fc32062d7b3f3c355fa7ca0d927df355426ac683/Makefile.in#L1329

MarinPostma pushed a commit that referenced this issue Oct 17, 2023
We'll migrate to it in a next PR, but for now it's dropped
as it was not intended to be added as part of #79.
MarinPostma pushed a commit that referenced this issue Oct 17, 2023
The following fixes are applied as a follow-up for #79:
 - memory allocated for virtual WAL methods is tracked
 - database handle created from rusqlite::Connection::from_handle
   is now manually closed in order to free resources
 - sqlite3_initialize() is no longer needed and is thus dropped
 - std::ptr::copy is used instead of creating slices for the same purpose
MarinPostma pushed a commit that referenced this issue Oct 17, 2023
The following fixes are applied as a follow-up for #79:
 - memory allocated for virtual WAL methods is tracked
 - database handle created from rusqlite::Connection::from_handle
   is now manually closed in order to free resources
 - sqlite3_initialize() is no longer needed and is thus dropped
 - std::ptr::copy is used instead of creating slices for the same purpose

In order to manually track the lifetimes of resources we allocate (a custom db handle and custom WAL methods), a thin wrapper around `rusqlite::Connection` is implemented - `WalConnection`. This wrapper implements `Deref` to `rusqlite::Connection`, so it's generally a drop-in replacement, except it knows how to properly deallocate the resources.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants