Skip to content

Commit

Permalink
Add bindings to the encryption extension
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanUkhov committed Apr 21, 2024
1 parent 803ff80 commit ff7d05f
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 3 deletions.
5 changes: 4 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,11 @@ keywords = ["database"]

[features]
default = ["linkage"]
bundled = ["sqlite3-src/bundled"]

linkage = ["sqlite3-src"]
bundled = ["sqlite3-src/bundled"]

encryption = []

[dependencies.sqlite3-src]
version = "0.6"
Expand Down
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@

The package provides bindings to [SQLite].

The following Cargo features are supported:

* `linkage` creates a dependency on `sqlite3-src`, which links to a suitable
SQLite library;
* `bundled` compiles SQLite from the source code, ignoring any libraries that
might be installed in the system; and
* `encryption` enables bindings to the [SQLite Encryption Extension], which is
closed source and hence requires purchasing a license and installing SQLite
manually.

## Development

```shell
Expand All @@ -19,6 +29,7 @@ pull request. Note that any contribution submitted for inclusion in the project
will be licensed according to the terms given in [LICENSE.md](LICENSE.md).

[SQLite]: https://www.sqlite.org
[SQLite Encryption Extension]: https://www.sqlite.org/see/doc/release/www/index.wiki

[build-img]: https://github.com/stainless-steel/sqlite3-sys/workflows/build/badge.svg
[build-url]: https://github.com/stainless-steel/sqlite3-sys/actions/workflows/build.yml
Expand Down
20 changes: 20 additions & 0 deletions src/encryption.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
use core::ffi::{c_char, c_int, c_void};

use crate::bindings::sqlite3;

extern "C" {
pub fn sqlite3_key(db: *mut sqlite3, pKey: *const c_void, nKey: c_int) -> c_int;
pub fn sqlite3_key_v2(
db: *mut sqlite3,
zDbName: *const c_char,
pKey: *const c_void,
nKey: c_int,
) -> c_int;
pub fn sqlite3_rekey(db: *mut sqlite3, pKey: *const c_void, nKey: c_int) -> c_int;
pub fn sqlite3_rekey_v2(
db: *mut sqlite3,
zDbName: *const c_char,
pKey: *const c_void,
nKey: c_int,
) -> c_int;
}
19 changes: 17 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
//! Bindings to [SQlite][1].
//! Bindings to [SQlite].
//!
//! [1]: https://www.sqlite.org
//! The following Cargo features are supported:
//!
//! * `linkage` creates a dependency on `sqlite3-src`, which links to a suitable
//! SQLite library;
//! * `bundled` compiles SQLite from the source code, ignoring any libraries that
//! might be installed in the system; and
//! * `encryption` enables bindings to the [SQLite Encryption Extension], which is
//! closed source and hence requires purchasing a license and installing SQLite
//! manually.
//!
//! [SQLite]: https://www.sqlite.org
//! [SQLite Encryption Extension]: https://www.sqlite.org/see/doc/release/www/index.wiki

#![allow(non_camel_case_types, non_snake_case)]
#![no_std]
Expand All @@ -9,5 +20,9 @@
extern crate sqlite3_src;

mod bindings;
#[cfg(feature = "encryption")]
mod encryption;

pub use bindings::*;
#[cfg(feature = "encryption")]
pub use encryption::*;

0 comments on commit ff7d05f

Please sign in to comment.