kernel::processbuffer

Struct WriteableProcessSlice

Source
pub struct WriteableProcessSlice { /* private fields */ }
Expand description

Read-writeable and accessible slice of memory of a process buffer

The only way to obtain this struct is through a ReadWriteProcessBuffer.

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 WriteableProcessSlice

Source

pub fn copy_to_slice(&self, dest: &mut [u8])

Copy the contents of a WriteableProcessSlice 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().

Source

pub fn copy_to_slice_or_err(&self, dest: &mut [u8]) -> Result<(), ErrorCode>

Copy the contents of a WriteableProcessSlice 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.

Source

pub fn copy_from_slice(&self, src: &[u8])

Copy the contents of a slice of bytes into a WriteableProcessSlice.

The length of src must be the same as self. Subslicing can be used to obtain a slice of matching length.

§Panics

This function will panic if src.len() != self.len().

Source

pub fn copy_from_slice_or_err(&self, src: &[u8]) -> Result<(), ErrorCode>

Copy the contents of a slice of bytes into a WriteableProcessSlice.

The length of src must be the same as self. Subslicing can be used to obtain a slice of matching length.

Source

pub fn len(&self) -> usize

Return the length of the slice in bytes.

Source

pub fn iter(&self) -> Iter<'_, Cell<u8>>

Return an iterator over the slice.

Source

pub fn chunks( &self, chunk_size: usize, ) -> impl Iterator<Item = &WriteableProcessSlice>

Iterate over the slice in chunks.

Source

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.

Source

pub fn get_from( &self, range: RangeFrom<usize>, ) -> Option<&WriteableProcessSlice>

👎Deprecated: Use WriteableProcessSlice::get instead

Access a portion of the slice with bounds checking. If the access is not within the slice then None is returned.

Source

pub fn get_to(&self, range: RangeTo<usize>) -> Option<&WriteableProcessSlice>

👎Deprecated: Use WriteableProcessSlice::get instead

Access a portion of the slice with bounds checking. If the access is not within the slice then None is returned.

Trait Implementations§

Source§

impl<'a> From<&'a mut [u8]> for &'a WriteableProcessSlice

Source§

fn from(val: &'a mut [u8]) -> Self

Converts to this type from the input type.
Source§

impl<I: ProcessSliceIndex<Self>> Index<I> for WriteableProcessSlice

Source§

type Output = <I as ProcessSliceIndex<WriteableProcessSlice>>::Output

The returned type after indexing.
Source§

fn index(&self, index: I) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl ProcessSliceIndex<WriteableProcessSlice> for Range<usize>

Source§

impl ProcessSliceIndex<WriteableProcessSlice> for RangeFrom<usize>

Source§

impl ProcessSliceIndex<WriteableProcessSlice> for RangeTo<usize>

Source§

impl ProcessSliceIndex<WriteableProcessSlice> for usize

Source§

type Output = Cell<u8>

Source§

fn get(self, slice: &WriteableProcessSlice) -> Option<&Self::Output>

Source§

fn index(self, slice: &WriteableProcessSlice) -> &Self::Output

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more