From a84a755cf7e3d786b50abd8944c9ec1da407d448 Mon Sep 17 00:00:00 2001 From: Pekka Enberg Date: Mon, 30 Jun 2025 12:36:20 +0300 Subject: [PATCH] bindings/rust: Add feature flag to enable indexes --- bindings/rust/Cargo.toml | 1 + bindings/rust/src/lib.rs | 16 ++++++++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/bindings/rust/Cargo.toml b/bindings/rust/Cargo.toml index f337038ca..557ad6e20 100644 --- a/bindings/rust/Cargo.toml +++ b/bindings/rust/Cargo.toml @@ -11,6 +11,7 @@ description = "Turso Rust API" [features] default = [] +experimental_indexes = [] antithesis = ["turso_core/antithesis"] [dependencies] diff --git a/bindings/rust/src/lib.rs b/bindings/rust/src/lib.rs index 4d4cdae19..465ca1ca9 100644 --- a/bindings/rust/src/lib.rs +++ b/bindings/rust/src/lib.rs @@ -83,18 +83,30 @@ impl Builder { match self.path.as_str() { ":memory:" => { let io: Arc = Arc::new(turso_core::MemoryIO::new()); - let db = turso_core::Database::open_file(io, self.path.as_str(), false, false)?; + let db = turso_core::Database::open_file( + io, + self.path.as_str(), + false, + indexes_enabled(), + )?; Ok(Database { inner: db }) } path => { let io: Arc = Arc::new(turso_core::PlatformIO::new()?); - let db = turso_core::Database::open_file(io, path, false, false)?; + let db = turso_core::Database::open_file(io, path, false, indexes_enabled())?; Ok(Database { inner: db }) } } } } +fn indexes_enabled() -> bool { + #[cfg(feature = "experimental_indexes")] + return true; + #[cfg(not(feature = "experimental_indexes"))] + return false; +} + /// A database. /// /// The `Database` object points to a database and allows you to connect to it