add map accessor to Database; move cork interface

Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
Jason Volk 2024-10-29 00:08:41 +00:00 committed by strawberry
parent 567a4cb441
commit 354dc9e703
3 changed files with 26 additions and 18 deletions

View file

@ -1,6 +1,6 @@
use std::sync::Arc;
use crate::Engine;
use crate::{Database, Engine};
pub struct Cork {
db: Arc<Engine>,
@ -8,6 +8,20 @@ pub struct Cork {
sync: bool,
}
impl Database {
#[inline]
#[must_use]
pub fn cork(&self) -> Cork { Cork::new(&self.db, false, false) }
#[inline]
#[must_use]
pub fn cork_and_flush(&self) -> Cork { Cork::new(&self.db, true, false) }
#[inline]
#[must_use]
pub fn cork_and_sync(&self) -> Cork { Cork::new(&self.db, true, true) }
}
impl Cork {
#[inline]
pub(super) fn new(db: &Arc<Engine>, flush: bool, sync: bool) -> Self {