From 593fd5fb88487bd696552978ea007b657e544ef0 Mon Sep 17 00:00:00 2001 From: Avinash Sajjanshetty Date: Thu, 2 Oct 2025 16:16:50 +0530 Subject: [PATCH] update Rust bindings to enable experimental encryption --- bindings/rust/src/lib.rs | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/bindings/rust/src/lib.rs b/bindings/rust/src/lib.rs index afe604226..093a71e7f 100644 --- a/bindings/rust/src/lib.rs +++ b/bindings/rust/src/lib.rs @@ -48,7 +48,7 @@ pub use params::IntoParams; use std::fmt::Debug; use std::num::NonZero; use std::sync::{Arc, Mutex}; - +use turso_core::OpenFlags; // Re-exports rows pub use crate::rows::{Row, Rows}; @@ -82,6 +82,7 @@ pub type Result = std::result::Result; pub struct Builder { path: String, enable_mvcc: bool, + enable_encryption: bool, vfs: Option, } @@ -91,6 +92,7 @@ impl Builder { Self { path: path.to_string(), enable_mvcc: false, + enable_encryption: false, vfs: None, } } @@ -100,6 +102,11 @@ impl Builder { self } + pub fn experimental_encryption(mut self, encryption_enabled: bool) -> Self { + self.enable_encryption = encryption_enabled; + self + } + pub fn with_io(mut self, vfs: String) -> Self { self.vfs = Some(vfs); self @@ -109,7 +116,16 @@ impl Builder { #[allow(unused_variables, clippy::arc_with_non_send_sync)] pub async fn build(self) -> Result { let io = self.get_io()?; - let db = turso_core::Database::open_file(io, self.path.as_str(), self.enable_mvcc, true)?; + let opts = turso_core::DatabaseOpts::default() + .with_mvcc(self.enable_mvcc) + .with_encryption(self.enable_encryption); + let db = turso_core::Database::open_file_with_flags( + io, + self.path.as_str(), + OpenFlags::default(), + opts, + None, + )?; Ok(Database { inner: db }) }