mirror of
https://github.com/aljazceru/turso.git
synced 2026-01-23 09:54:26 +01:00
Merge 'bindings/rust: add with_mvcc option' from Pere Diaz Bou
Closes #2442
This commit is contained in:
@@ -81,6 +81,7 @@ pub type Result<T> = std::result::Result<T, Error>;
|
||||
/// 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<Database> {
|
||||
@@ -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<dyn turso_core::IO> = 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 })
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user