pub struct PtrByteSlice<'a> { /* private fields */ }Expand description
A read-only view of a raw pointer byte slice, providing a safe API.
Implementations§
Source§impl<'a> PtrByteSlice<'a>
impl<'a> PtrByteSlice<'a>
Sourcepub unsafe fn new(slice: *const [u8]) -> Self
pub unsafe fn new(slice: *const [u8]) -> Self
Creates a new PtrByteSlice from a raw pointer to a byte slice.
§Safety
The caller must ensure that slice is valid for reads 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 as_raw_slice_ptr(&self) -> *const [u8]
pub fn as_raw_slice_ptr(&self) -> *const [u8]
Returns the raw pointer to the slice.
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> Clone for PtrByteSlice<'a>
impl<'a> Clone for PtrByteSlice<'a>
Source§fn clone(&self) -> PtrByteSlice<'a>
fn clone(&self) -> PtrByteSlice<'a>
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<'a> Debug for PtrByteSlice<'a>
impl<'a> Debug for PtrByteSlice<'a>
Source§impl<'a> From<&'a [u8]> for PtrByteSlice<'a>
impl<'a> From<&'a [u8]> for PtrByteSlice<'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<'a> Copy for PtrByteSlice<'a>
impl Send for PtrByteSlice<'_>
impl Sync for PtrByteSlice<'_>
Auto Trait Implementations§
impl<'a> Freeze for PtrByteSlice<'a>
impl<'a> RefUnwindSafe for PtrByteSlice<'a>
impl<'a> Unpin for PtrByteSlice<'a>
impl<'a> UnsafeUnpin for PtrByteSlice<'a>
impl<'a> UnwindSafe for PtrByteSlice<'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