From 2392ea1b55ee1c0668950c5f77a4e2a5296a0e54 Mon Sep 17 00:00:00 2001 From: Pere Diaz Bou Date: Tue, 5 Aug 2025 11:27:37 +0200 Subject: [PATCH] bindings/rust: add with_mvcc option --- bindings/rust/src/lib.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/bindings/rust/src/lib.rs b/bindings/rust/src/lib.rs index ebaa0293c..79560491e 100644 --- a/bindings/rust/src/lib.rs +++ b/bindings/rust/src/lib.rs @@ -81,6 +81,7 @@ pub type Result = std::result::Result; /// A builder for `Database`. pub struct Builder { path: String, + enable_mvcc: bool, } impl Builder { @@ -88,9 +89,15 @@ impl Builder { pub fn new_local(path: &str) -> Self { Self { path: path.to_string(), + enable_mvcc: false, } } + pub fn with_mvcc(mut self, mvcc_enabled: bool) -> Self { + self.enable_mvcc = mvcc_enabled; + self + } + /// Build the database. #[allow(unused_variables, clippy::arc_with_non_send_sync)] pub async fn build(self) -> Result { @@ -100,14 +107,15 @@ impl Builder { let db = turso_core::Database::open_file( io, self.path.as_str(), - false, + self.enable_mvcc, 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, indexes_enabled())?; + let db = + turso_core::Database::open_file(io, path, self.enable_mvcc, indexes_enabled())?; Ok(Database { inner: db }) } }