ps_buffer/methods/
alloc.rs

1use crate::{constants::FILLER, Buffer, BufferError};
2
3impl Buffer {
4    #[inline]
5    /// Allocates a `Buffer` and initializes its content.
6    /// # Errors
7    /// `AllocationError` is returned if allocation fails.
8    pub fn alloc(length: usize) -> Result<Self, BufferError> {
9        let mut buffer = Self::default();
10
11        buffer.resize(length, FILLER)?;
12
13        Ok(buffer)
14    }
15}