ps-buffer 0.1.0-21

aligned heap buffer
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use crate::{Buffer, BufferError};

impl Buffer {
    /// - Ensures the are at least a total of `capacity` bytes reserved in this [`Buffer`].
    /// - The current length of this [`Buffer`] is not taken into consideration.
    /// - You might be looking for [`Buffer::reserve`].
    /// # Errors
    /// - `AllocationError` is returned if allocation fails.
    /// - `DeallocationError` is returned if deallocation fails.
    pub fn reserve_total(&mut self, capacity: usize) -> Result<&mut Self, BufferError> {
        if capacity > self.capacity() {
            self.realloc(capacity)?;
        }

        Ok(self)
    }
}