Struct MemoryMap

Source
pub struct MemoryMap<T> { /* private fields */ }
Expand description

Memory mapped IO

Implementations§

Source§

impl<T> MemoryMap<T>

Source

pub fn read(&self) -> T

Reads data

Source

pub fn write(&mut self, val: T)

Writes data

Source

pub fn read_and_write<F: FnOnce(T) -> T>(&mut self, cb: F)

Gives callback to accept value to return modified value to write.

Source

pub fn as_ref<'a>(&'a mut self) -> RawPtr<'a, T>

Access raw pointer

Note that, ownership is not transferred

Source

pub unsafe fn open_file_raw( offset: off_t, fd: c_int, prot: c_int, flags: c_int, ) -> Option<Self>

Opens memory map.

§Arguments
  • offset - Offset within memory to start.
  • fd - File description. -1 for anonymous.
  • prot - Memory protection. Specifies operations to be expected. At the very least must be PROT_READ | PROT_WRITE
  • flags - Specifies whether changes to the mapping are visible across forks. Must be MAP_ANON for anonymous.
Source

pub fn anonymous() -> Option<Self>

Creates anonymous memory mapping

Source

pub unsafe fn dev_mem(offset: off_t) -> Option<Self>

Creates memory mapping on /dev/mem which accesses physical memory

§Arguments
  • offset - Offset within memory to start.

Returns None on error, further details can be examined by checking last IO error.

Trait Implementations§

Source§

impl<T> Debug for MemoryMap<T>

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<T> Drop for MemoryMap<T>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl<T> Pointer for MemoryMap<T>

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<T> Send for MemoryMap<T>

Source§

impl<T> Sync for MemoryMap<T>

Auto Trait Implementations§

§

impl<T> Freeze for MemoryMap<T>

§

impl<T> RefUnwindSafe for MemoryMap<T>
where T: RefUnwindSafe,

§

impl<T> Unpin for MemoryMap<T>

§

impl<T> UnwindSafe for MemoryMap<T>
where T: RefUnwindSafe,

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.