update Rust bindings to enable experimental encryption

This commit is contained in:
Avinash Sajjanshetty
2025-10-02 16:16:50 +05:30
parent 68425fbe92
commit 593fd5fb88

View File

@@ -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<T> = std::result::Result<T, Error>;
pub struct Builder {
path: String,
enable_mvcc: bool,
enable_encryption: bool,
vfs: Option<String>,
}
@@ -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<Database> {
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 })
}