Skip to main content

MemoryAccess

Struct MemoryAccess 

Source
pub struct MemoryAccess<'a> { /* private fields */ }

Implementations§

Source§

impl<'a> MemoryAccess<'a>

Source

pub unsafe fn new(ptr: *mut u8, size: usize) -> Self

Creates a new memory access wrapper from a raw pointer and size.

§Safety

The caller must ensure the pointer points to valid memory of at least ‘size’ bytes and remains valid for the lifetime ’a.

Source

pub fn read<T: Copy>(&self, offset: usize) -> T

Reads a value of type T from the offset.

§Panics

Panics if the read would go out of bounds.

Source

pub fn write<T>(&mut self, offset: usize, value: T)

Writes a value of type T at the offset.

§Panics

Panics if the write would go out of bounds.

Source

pub fn slice(&self, offset: usize, len: usize) -> &[u8]

Gets a slice of the memory.

§Panics

Panics if the slice would go out of bounds.

Source

pub fn slice_mut(&mut self, offset: usize, len: usize) -> &mut [u8]

Gets a mutable slice of the memory.

§Panics

Panics if the slice would go out of bounds.

Trait Implementations§

Source§

impl<'a> Debug for MemoryAccess<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> !Send for MemoryAccess<'a>

§

impl<'a> !Sync for MemoryAccess<'a>

§

impl<'a> !UnwindSafe for MemoryAccess<'a>

§

impl<'a> Freeze for MemoryAccess<'a>

§

impl<'a> RefUnwindSafe for MemoryAccess<'a>

§

impl<'a> Unpin for MemoryAccess<'a>

§

impl<'a> UnsafeUnpin for MemoryAccess<'a>

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
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.