adjust DatabaseStorage trait to return completions

This commit is contained in:
pedrocarlo
2025-07-28 12:27:55 -03:00
parent 0088e3e1a9
commit 3104e3fee5
3 changed files with 35 additions and 39 deletions

View File

@@ -690,7 +690,11 @@ impl DatabaseFile {
}
impl turso_core::DatabaseStorage for DatabaseFile {
fn read_page(&self, page_idx: usize, c: turso_core::Completion) -> turso_core::Result<()> {
fn read_page(
&self,
page_idx: usize,
c: turso_core::Completion,
) -> turso_core::Result<Arc<turso_core::Completion>> {
let r = match c.completion_type {
turso_core::CompletionType::Read(ref r) => r,
_ => unreachable!(),
@@ -701,8 +705,7 @@ impl turso_core::DatabaseStorage for DatabaseFile {
return Err(turso_core::LimboError::NotADB);
}
let pos = (page_idx - 1) * size;
self.file.pread(pos, c.into())?;
Ok(())
self.file.pread(pos, c.into())
}
fn write_page(
@@ -710,16 +713,14 @@ impl turso_core::DatabaseStorage for DatabaseFile {
page_idx: usize,
buffer: Arc<std::cell::RefCell<turso_core::Buffer>>,
c: turso_core::Completion,
) -> turso_core::Result<()> {
) -> turso_core::Result<Arc<turso_core::Completion>> {
let size = buffer.borrow().len();
let pos = (page_idx - 1) * size;
self.file.pwrite(pos, buffer, c.into())?;
Ok(())
self.file.pwrite(pos, buffer, c.into())
}
fn sync(&self, c: turso_core::Completion) -> turso_core::Result<()> {
let _ = self.file.sync(c.into())?;
Ok(())
fn sync(&self, c: turso_core::Completion) -> turso_core::Result<Arc<turso_core::Completion>> {
self.file.sync(c.into())
}
fn size(&self) -> turso_core::Result<u64> {