pub type HeapBuffer = CircularBuffer<Vec<u8>>;Available on crate feature
alloc only.Expand description
A circular buffer backed by a heap-allocated Vec<u8>.
Requires the alloc feature (enabled by default).
Aliased Type§
pub struct HeapBuffer { /* private fields */ }Implementations§
Source§impl HeapBuffer
impl HeapBuffer
Sourcepub fn try_resize(&mut self, new_capacity: usize) -> Result<(), usize>
pub fn try_resize(&mut self, new_capacity: usize) -> Result<(), usize>
Attempts to resize the buffer to a new_capacity.
§Growing
If new_capacity is larger than the current capacity, the buffer is extended.
§Shrinking
If new_capacity is smaller, the buffer attempts to shrink.
- This operation forces the buffer to become contiguous (see
make_contiguous). - The operation fails if the active data (
remaining()) is larger thannew_capacity.
§Errors
Returns Err(usize) if the buffer cannot be shrunk because it currently holds too much data.
The error value is the number of bytes that must be consumed (read) before this resize can succeed.
§Panics
Panics if new_capacity is 0.