pub struct AlignedBuffer { /* private fields */ }Implementations§
Source§impl AlignedBuffer
impl AlignedBuffer
Sourcepub fn new(capacity: usize) -> Result<Self>
pub fn new(capacity: usize) -> Result<Self>
Create a new aligned buffer with the given capacity.
§Errors
Returns an error if memory allocation fails.
pub fn as_ptr(&self) -> *const u8
pub fn as_mut_ptr(&mut self) -> *mut u8
pub fn as_slice(&self) -> &[u8] ⓘ
pub fn as_mut_slice(&mut self) -> &mut [u8] ⓘ
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
pub fn capacity(&self) -> usize
pub fn set_len(&mut self, len: usize)
pub fn clear(&mut self)
Sourcepub fn mlock(&self) -> Result<()>
pub fn mlock(&self) -> Result<()>
Lock the buffer in memory using mlock to prevent page faults. This ensures the buffer pages are resident in RAM and won’t be swapped.
§Errors
Returns an error if mlock fails (e.g., insufficient privileges or limits).
Sourcepub fn prefault(&mut self)
pub fn prefault(&mut self)
Prefault all pages in the buffer by touching each page. This ensures pages are allocated and mapped before use on the hot path.
Sourcepub fn lock_and_prefault(&mut self) -> Result<()>
pub fn lock_and_prefault(&mut self) -> Result<()>
Lock and prefault the buffer for zero-latency access on hot path.
§Errors
Returns an error if mlock fails.
Trait Implementations§
Source§impl Drop for AlignedBuffer
impl Drop for AlignedBuffer
impl Send for AlignedBuffer
impl Sync for AlignedBuffer
Auto Trait Implementations§
impl Freeze for AlignedBuffer
impl RefUnwindSafe for AlignedBuffer
impl Unpin for AlignedBuffer
impl UnsafeUnpin for AlignedBuffer
impl UnwindSafe for AlignedBuffer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more