mirror of
https://github.com/aljazceru/turso.git
synced 2026-01-19 16:14:21 +01:00
change completion callbacks to take a Result param + create separate functions to declare a completion errored
This commit is contained in:
@@ -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)?;
|
||||
|
||||
@@ -53,7 +53,12 @@ impl IoOperations for Arc<dyn turso_core::IO> {
|
||||
file: Arc<dyn turso_core::File>,
|
||||
len: usize,
|
||||
) -> Result<()> {
|
||||
let c = Completion::new_trunc(move |rc| tracing::debug!("file truncated: rc={}", rc));
|
||||
let c = Completion::new_trunc(move |rc| {
|
||||
let Ok(rc) = rc else {
|
||||
return;
|
||||
};
|
||||
tracing::debug!("file truncated: rc={}", rc);
|
||||
});
|
||||
let c = file.truncate(len, c)?;
|
||||
while !c.is_completed() {
|
||||
coro.yield_(ProtocolCommand::IO).await?;
|
||||
|
||||
Reference in New Issue
Block a user