diff --git a/src/producer/prealloc.rs b/src/producer/prealloc.rs index 9e8207d..9538102 100644 --- a/src/producer/prealloc.rs +++ b/src/producer/prealloc.rs @@ -17,12 +17,17 @@ pub struct PreAlloc { } impl PreAlloc { - /// Get the slice of the pre-allocated. + /// Get the slice of the [`PreAlloc`]. pub fn slice(&self) -> &[u8] { self.data_block.slice().unwrap() } - /// Write data to the pre-allocated. + /// Get the capacity of the [`PreAlloc`]. + pub fn capacity(&self) -> u32 { + self.data_block.capacity() + } + + /// Write data to the [`PreAlloc`]. pub fn write(&mut self, data: &[u8]) -> Result<()> { self.data_block.write(data) } diff --git a/src/ringbuf/data_block.rs b/src/ringbuf/data_block.rs index d6a5343..58f1951 100644 --- a/src/ringbuf/data_block.rs +++ b/src/ringbuf/data_block.rs @@ -147,7 +147,7 @@ impl DataBlock { self.capacity() + HEADER_LEN as u32 } - fn capacity(&self) -> u32 { + pub(crate) fn capacity(&self) -> u32 { self.header.capacity() }