Get the written portion padded up to the next alignment boundary. O_DIRECT requires the I/O size to be a multiple of the block size. The padding bytes are zeroed (from `alloc_zeroed`).
(&self)
| 116 | /// O_DIRECT requires the I/O size to be a multiple of the block size. |
| 117 | /// The padding bytes are zeroed (from `alloc_zeroed`). |
| 118 | pub fn as_aligned_slice(&self) -> &[u8] { |
| 119 | let aligned_len = round_up(self.len, self.alignment); |
| 120 | let actual_len = aligned_len.min(self.capacity); |
| 121 | // SAFETY: ptr is valid for `capacity` bytes, and actual_len <= capacity. |
| 122 | unsafe { std::slice::from_raw_parts(self.ptr, actual_len) } |
| 123 | } |
| 124 | |
| 125 | /// Reset the buffer for reuse without deallocating. |
| 126 | pub fn clear(&mut self) { |
no test coverage detected