Skip to content

Commit aa011b4

Browse files
committed
add partial ZerocopyBoxIoBuf
1 parent e55dd89 commit aa011b4

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

libsql-wal/src/io/buf.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,17 @@ impl<T> ZeroCopyBoxIoBuf<T> {
154154
Self { init: 0, inner }
155155
}
156156

157+
/// same as new_uninit, but partially fills the buffer starting at offset
158+
///
159+
/// # Safety: The caller must ensure that the remaining bytes are initialized
160+
pub unsafe fn new_uninit_partial(inner: Box<T>, offset: usize) -> Self {
161+
assert!(offset < size_of::<T>());
162+
Self {
163+
inner,
164+
init: offset,
165+
}
166+
}
167+
157168
fn is_init(&self) -> bool {
158169
self.init == size_of::<T>()
159170
}

0 commit comments

Comments
 (0)