rename db to engine

This commit is contained in:
dasha_uwu authored and Jason Volk committed 2025-09-23 05:16:29 +00:00
1 parent e0169e3dca
commit b882e7efdb
25 files changed
+98 -87

No files matched your search

+10 -10
View File
@@ -3,7 +3,7 @@ use std::sync::Arc;
use crate::{Database, Engine};
pub struct Cork {
db: Arc<Engine>,
engine: Arc<Engine>,
flush: bool,
sync: bool,
}
@@ -11,33 +11,33 @@ pub struct Cork {
impl Database {
#[inline]
#[must_use]
pub fn cork(&self) -> Cork { Cork::new(&self.db, false, false) }
pub fn cork(&self) -> Cork { Cork::new(&self.engine, false, false) }
#[inline]
#[must_use]
pub fn cork_and_flush(&self) -> Cork { Cork::new(&self.db, true, false) }
pub fn cork_and_flush(&self) -> Cork { Cork::new(&self.engine, true, false) }
#[inline]
#[must_use]
pub fn cork_and_sync(&self) -> Cork { Cork::new(&self.db, true, true) }
pub fn cork_and_sync(&self) -> Cork { Cork::new(&self.engine, true, true) }
}
impl Cork {
#[inline]
pub(super) fn new(db: &Arc<Engine>, flush: bool, sync: bool) -> Self {
db.cork();
Self { db: db.clone(), flush, sync }
pub(super) fn new(engine: &Arc<Engine>, flush: bool, sync: bool) -> Self {
engine.cork();
Self { engine: engine.clone(), flush, sync }
}
}
impl Drop for Cork {
fn drop(&mut self) {
self.db.uncork();
self.engine.uncork();
if self.flush {
self.db.flush().ok();
self.engine.flush().ok();
}
if self.sync {
self.db.sync().ok();
self.engine.sync().ok();
}
}
}