pub struct MutPtrByteSlice<'a> { /* private fields */ }Expand description
A mutable view of a raw pointer byte slice, providing a safe API.
Implementations§
Source§impl<'a> MutPtrByteSlice<'a>
impl<'a> MutPtrByteSlice<'a>
Sourcepub unsafe fn new(slice: *mut [u8]) -> Self
pub unsafe fn new(slice: *mut [u8]) -> Self
Creates a new MutPtrByteSlice from a raw mutable pointer to a byte slice.
§Safety
The caller must ensure that slice is valid for reads and writes for the lifetime 'a.
Sourcepub fn copy_to_slice(&self, dest: &mut [u8])
pub fn copy_to_slice(&self, dest: &mut [u8])
Copies the contents of this slice into a safe Rust mutable slice.
§Panics
Panics if dest is smaller than self.len().
Sourcepub fn copy_from_ptr_slice(&mut self, src: PtrByteSlice<'_>)
pub fn copy_from_ptr_slice(&mut self, src: PtrByteSlice<'_>)
Copies the contents of another read-only pointer slice into this mutable slice.
§Panics
Panics if the lengths of the slices do not match.
Sourcepub fn as_ptr_slice(&self) -> PtrByteSlice<'_>
pub fn as_ptr_slice(&self) -> PtrByteSlice<'_>
Returns a read-only view of this slice.
Sourcepub fn subslice_mut(&mut self, range: Range<usize>) -> Self
pub fn subslice_mut(&mut self, range: Range<usize>) -> Self
Sourcepub fn split_at_mut(self, mid: usize) -> (Self, Self)
pub fn split_at_mut(self, mid: usize) -> (Self, Self)
Sourcepub fn as_mut_ptr(&self) -> *mut u8
pub fn as_mut_ptr(&self) -> *mut u8
Returns a raw mutable pointer to the start of the slice.
Sourcepub fn reborrow(&mut self) -> MutPtrByteSlice<'_>
pub fn reborrow(&mut self) -> MutPtrByteSlice<'_>
Reborrows the mutable slice with a shorter lifetime.
Sourcepub fn to_vec(&self) -> Vec<u8> ⓘ
pub fn to_vec(&self) -> Vec<u8> ⓘ
Allocates a new heap Vector and copies the contents into it. Bypasses zero-initialization using raw pointer copies.
Trait Implementations§
Source§impl<'a> Debug for MutPtrByteSlice<'a>
impl<'a> Debug for MutPtrByteSlice<'a>
Source§impl<'a> From<&'a mut [u8]> for MutPtrByteSlice<'a>
impl<'a> From<&'a mut [u8]> for MutPtrByteSlice<'a>
Source§impl<'a> From<MutPtrByteSlice<'a>> for PtrByteSlice<'a>
impl<'a> From<MutPtrByteSlice<'a>> for PtrByteSlice<'a>
Source§fn from(slice: MutPtrByteSlice<'a>) -> Self
fn from(slice: MutPtrByteSlice<'a>) -> Self
Converts to this type from the input type.
impl Send for MutPtrByteSlice<'_>
impl Sync for MutPtrByteSlice<'_>
Auto Trait Implementations§
impl<'a> Freeze for MutPtrByteSlice<'a>
impl<'a> RefUnwindSafe for MutPtrByteSlice<'a>
impl<'a> Unpin for MutPtrByteSlice<'a>
impl<'a> UnsafeUnpin for MutPtrByteSlice<'a>
impl<'a> !UnwindSafe for MutPtrByteSlice<'a>
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