pub struct AlignedMemory<const ALIGN: usize> { /* private fields */ }Expand description
Provides u8 slices at a specified alignment
Implementations§
Source§impl<const ALIGN: usize> AlignedMemory<ALIGN>
impl<const ALIGN: usize> AlignedMemory<ALIGN>
Sourcepub fn from_slice(data: &[u8]) -> Self
pub fn from_slice(data: &[u8]) -> Self
Returns a filled AlignedMemory by copying the given slice
Sourcepub fn with_capacity(max_len: usize) -> Self
pub fn with_capacity(max_len: usize) -> Self
Returns a new empty AlignedMemory with uninitialized preallocated memory
Sourcepub fn with_capacity_zeroed(max_len: usize) -> Self
pub fn with_capacity_zeroed(max_len: usize) -> Self
Returns a new empty AlignedMemory with zero initialized preallocated memory
Sourcepub fn zero_filled(max_len: usize) -> Self
pub fn zero_filled(max_len: usize) -> Self
Returns a new filled AlignedMemory with zero initialized preallocated memory
Sourcepub fn write_index(&self) -> usize
pub fn write_index(&self) -> usize
Get the current write index
Sourcepub fn as_slice_mut(&mut self) -> &mut [u8] ⓘ
pub fn as_slice_mut(&mut self) -> &mut [u8] ⓘ
Get an aligned mutable slice
Sourcepub fn fill_write(&mut self, num: usize, value: u8) -> Result<()>
pub fn fill_write(&mut self, num: usize, value: u8) -> Result<()>
Grows memory with value repeated num times starting at the write_index
Sourcepub unsafe fn write_unchecked<T: Pod>(&mut self, value: T)
pub unsafe fn write_unchecked<T: Pod>(&mut self, value: T)
Write a generic type T into the memory.
§Safety
Unsafe since it assumes that there is enough capacity.
Sourcepub unsafe fn write_all_unchecked(&mut self, value: &[u8])
pub unsafe fn write_all_unchecked(&mut self, value: &[u8])
Write a slice of bytes into the memory.
§Safety
Unsafe since it assumes that there is enough capacity.
Trait Implementations§
Source§impl<const ALIGN: usize> Clone for AlignedMemory<ALIGN>
impl<const ALIGN: usize> Clone for AlignedMemory<ALIGN>
Source§impl<const ALIGN: usize> Debug for AlignedMemory<ALIGN>
impl<const ALIGN: usize> Debug for AlignedMemory<ALIGN>
Source§impl<const ALIGN: usize> PartialEq for AlignedMemory<ALIGN>
impl<const ALIGN: usize> PartialEq for AlignedMemory<ALIGN>
Source§impl<const ALIGN: usize> Write for AlignedMemory<ALIGN>
impl<const ALIGN: usize> Write for AlignedMemory<ALIGN>
Source§fn write(&mut self, buf: &[u8]) -> Result<usize>
fn write(&mut self, buf: &[u8]) -> Result<usize>
Writes a buffer into this writer, returning how many bytes were written. Read more
Source§fn flush(&mut self) -> Result<()>
fn flush(&mut self) -> Result<()>
Flushes this output stream, ensuring that all intermediately buffered
contents reach their destination. Read more
Source§fn is_write_vectored(&self) -> bool
fn is_write_vectored(&self) -> bool
🔬This is a nightly-only experimental API. (
can_vector)1.0.0 · Source§fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
Attempts to write an entire buffer into this writer. Read more
Source§fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
🔬This is a nightly-only experimental API. (
write_all_vectored)Attempts to write multiple buffers into this writer. Read more
impl<const ALIGN: usize> Eq for AlignedMemory<ALIGN>
impl<const ALIGN: usize> StructuralPartialEq for AlignedMemory<ALIGN>
Auto Trait Implementations§
impl<const ALIGN: usize> Freeze for AlignedMemory<ALIGN>
impl<const ALIGN: usize> RefUnwindSafe for AlignedMemory<ALIGN>
impl<const ALIGN: usize> Send for AlignedMemory<ALIGN>
impl<const ALIGN: usize> Sync for AlignedMemory<ALIGN>
impl<const ALIGN: usize> Unpin for AlignedMemory<ALIGN>
impl<const ALIGN: usize> UnwindSafe for AlignedMemory<ALIGN>
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