pub struct AlignedBuffer<T> { /* private fields */ }Expand description
A buffer with guaranteed SIMD-friendly alignment
This buffer ensures that data is aligned to the specified boundary, which is critical for efficient SIMD operations. It uses Rust’s global allocator with custom alignment.
Implementations§
Source§impl<T> AlignedBuffer<T>
impl<T> AlignedBuffer<T>
Sourcepub fn new(capacity: usize, align: usize) -> Result<Self>
pub fn new(capacity: usize, align: usize) -> Result<Self>
Create a new aligned buffer with the specified capacity and alignment
§Arguments
capacity- Number of elements to allocatealign- Alignment in bytes (must be a power of 2)
§Errors
Returns an error if:
- Alignment is not a power of 2
- Alignment is less than the natural alignment of T
- Memory allocation fails
Sourcepub fn as_mut_ptr(&mut self) -> *mut T
pub fn as_mut_ptr(&mut self) -> *mut T
Get a mutable raw pointer to the buffer
Sourcepub fn as_mut_slice(&mut self) -> &mut [T]
pub fn as_mut_slice(&mut self) -> &mut [T]
Get the buffer as a mutable slice
Sourcepub fn copy_from_slice(&mut self, src: &[T]) -> Result<()>where
T: Copy,
pub fn copy_from_slice(&mut self, src: &[T]) -> Result<()>where
T: Copy,
Copy data from a slice into the buffer
§Errors
Returns an error if the slice length doesn’t match the buffer capacity
Sourcepub fn strided_view(&self, stride: usize) -> Result<StridedView<'_, T>>
pub fn strided_view(&self, stride: usize) -> Result<StridedView<'_, T>>
Trait Implementations§
Source§impl<T> Drop for AlignedBuffer<T>
impl<T> Drop for AlignedBuffer<T>
impl<T: Send> Send for AlignedBuffer<T>
impl<T: Sync> Sync for AlignedBuffer<T>
Auto Trait Implementations§
impl<T> Freeze for AlignedBuffer<T>
impl<T> RefUnwindSafe for AlignedBuffer<T>where
T: RefUnwindSafe,
impl<T> Unpin for AlignedBuffer<T>
impl<T> UnsafeUnpin for AlignedBuffer<T>
impl<T> UnwindSafe for AlignedBuffer<T>where
T: RefUnwindSafe,
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