mirror of
https://github.com/aljazceru/turso.git
synced 2026-01-07 10:14:21 +01:00
bindings/rust: Add feature flag to enable indexes
This commit is contained in:
@@ -11,6 +11,7 @@ description = "Turso Rust API"
|
||||
|
||||
[features]
|
||||
default = []
|
||||
experimental_indexes = []
|
||||
antithesis = ["turso_core/antithesis"]
|
||||
|
||||
[dependencies]
|
||||
|
||||
@@ -83,18 +83,30 @@ impl Builder {
|
||||
match self.path.as_str() {
|
||||
":memory:" => {
|
||||
let io: Arc<dyn turso_core::IO> = 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<dyn turso_core::IO> = 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
|
||||
|
||||
Reference in New Issue
Block a user