Struct kernel::processbuffer::ReadableProcessSlice
source · pub struct ReadableProcessSlice { /* private fields */ }
Expand description
Readable and accessible slice of memory of a process buffer.
The only way to obtain this struct is through a
ReadWriteProcessBuffer
or ReadOnlyProcessBuffer
.
Slices provide a more convenient, traditional interface to process memory. These slices are transient, as the underlying buffer must be checked each time a slice is created. This is usually enforced by the anonymous lifetime defined by the creation of the slice.
Implementations§
source§impl ReadableProcessSlice
impl ReadableProcessSlice
sourcepub fn copy_to_slice(&self, dest: &mut [u8])
pub fn copy_to_slice(&self, dest: &mut [u8])
Copy the contents of a ReadableProcessSlice
into a mutable
slice reference.
The length of self
must be the same as dest
. Subslicing
can be used to obtain a slice of matching length.
§Panics
This function will panic if self.len() != dest.len()
.
sourcepub fn copy_to_slice_or_err(&self, dest: &mut [u8]) -> Result<(), ErrorCode>
pub fn copy_to_slice_or_err(&self, dest: &mut [u8]) -> Result<(), ErrorCode>
Copy the contents of a ReadableProcessSlice
into a mutable
slice reference.
The length of self
must be the same as dest
. Subslicing
can be used to obtain a slice of matching length.
sourcepub fn iter(&self) -> Iter<'_, ReadableProcessByte>
pub fn iter(&self) -> Iter<'_, ReadableProcessByte>
Return an iterator over the bytes of the slice.
sourcepub fn chunks(
&self,
chunk_size: usize,
) -> impl Iterator<Item = &ReadableProcessSlice>
pub fn chunks( &self, chunk_size: usize, ) -> impl Iterator<Item = &ReadableProcessSlice>
Iterate the slice in chunks.
sourcepub fn get<I: ProcessSliceIndex<Self>>(
&self,
index: I,
) -> Option<&<I as ProcessSliceIndex<Self>>::Output>
pub fn get<I: ProcessSliceIndex<Self>>( &self, index: I, ) -> Option<&<I as ProcessSliceIndex<Self>>::Output>
Access a portion of the slice with bounds checking. If the access is not
within the slice then None
is returned.