Skip to content

Commit

Permalink
Put extensions behind a feature flag
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanUkhov committed Nov 8, 2023
1 parent 76d20d4 commit c6fd6f9
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ keywords = ["database"]
[features]
default = ["linkage"]
bundled = ["sqlite3-sys/bundled"]
extension = []
linkage = ["sqlite3-sys/linkage"]

[dependencies]
Expand Down
3 changes: 3 additions & 0 deletions src/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ impl Connection {
}

/// Enable loading extensions.
#[cfg(feature = "extension")]
#[inline]
pub fn enable_extension(&self) -> Result<()> {
unsafe {
Expand All @@ -195,6 +196,7 @@ impl Connection {
}

/// Disable loading extensions.
#[cfg(feature = "extension")]
#[inline]
pub fn disable_extension(&self) -> Result<()> {
unsafe {
Expand All @@ -207,6 +209,7 @@ impl Connection {
}

/// Load an extension.
#[cfg(feature = "extension")]
#[inline]
pub fn load_extension<T: AsRef<str>>(&self, name: T) -> Result<()> {
unsafe {
Expand Down
3 changes: 3 additions & 0 deletions tests/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,18 +114,21 @@ fn set_busy_handler() {
}
}

#[cfg(feature = "extension")]
#[test]
fn enable_extension() {
let connection = ok!(Connection::open(":memory:"));
ok!(connection.enable_extension());
}

#[cfg(feature = "extension")]
#[test]
fn disable_extension() {
let connection = ok!(Connection::open(":memory:"));
ok!(connection.disable_extension());
}

#[cfg(feature = "extension")]
#[test]
fn load_extension() {
let connection = ok!(Connection::open(":memory:"));
Expand Down

0 comments on commit c6fd6f9

Please sign in to comment.