Skip to content

Commit

Permalink
add partial ZerocopyBoxIoBuf
Browse files Browse the repository at this point in the history
  • Loading branch information
MarinPostma committed Oct 4, 2024
1 parent e55dd89 commit aa011b4
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions libsql-wal/src/io/buf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,17 @@ impl<T> ZeroCopyBoxIoBuf<T> {
Self { init: 0, inner }
}

/// same as new_uninit, but partially fills the buffer starting at offset
///
/// # Safety: The caller must ensure that the remaining bytes are initialized
pub unsafe fn new_uninit_partial(inner: Box<T>, offset: usize) -> Self {
assert!(offset < size_of::<T>());
Self {
inner,
init: offset,
}
}

fn is_init(&self) -> bool {
self.init == size_of::<T>()
}
Expand Down

0 comments on commit aa011b4

Please sign in to comment.