change completion callbacks to take a Result param + create separate functions to declare a completion errored

This commit is contained in:
pedrocarlo
2025-08-13 17:17:14 -03:00
parent 71ca221390
commit ab3b68e360
9 changed files with 114 additions and 43 deletions

View File

@@ -74,7 +74,10 @@ pub async fn db_bootstrap<C: ProtocolIO>(
buffer.as_mut_slice().copy_from_slice(chunk);
let mut completions = Vec::with_capacity(dbs.len());
for db in dbs {
let c = Completion::new_write(move |size| {
let c = Completion::new_write(move |res| {
let Ok(size) = res else {
return;
};
// todo(sivukhin): we need to error out in case of partial read
assert!(size as usize == content_len);
});
@@ -818,7 +821,10 @@ pub async fn reset_wal_file(
WAL_HEADER + WAL_FRAME_SIZE * (frames_count as usize)
};
tracing::debug!("reset db wal to the size of {} frames", frames_count);
let c = Completion::new_trunc(move |rc| {
let c = Completion::new_trunc(move |res| {
let Ok(rc) = res else {
return;
};
assert!(rc as usize == 0);
});
let c = wal.truncate(wal_size, c)?;