Struct Memory

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

Emulates main memory.

Implementations§

Source§

impl Memory

Source

pub fn new() -> Self

Creates a new Memory

Source

pub fn init(&mut self, capacity: u64)

Initializes memory content. This method is expected to be called only once.

§Arguments
  • capacity
Source

pub fn read_byte(&self, address: u64) -> u8

Reads a byte from memory.

§Arguments
  • address
Source

pub fn read_halfword(&self, address: u64) -> u16

Reads two bytes from memory.

§Arguments
  • address
Source

pub fn read_word(&self, address: u64) -> u32

Reads four bytes from memory.

§Arguments
  • address
Source

pub fn read_doubleword(&self, address: u64) -> u64

Reads eight bytes from memory.

§Arguments
  • address
Source

pub fn read_bytes(&self, address: u64, width: u64) -> u64

Reads multiple bytes from memory.

§Arguments
  • address
  • width up to eight
Source

pub fn write_byte(&mut self, address: u64, value: u8)

Writes a byte to memory.

§Arguments
  • address
  • value
Source

pub fn write_halfword(&mut self, address: u64, value: u16)

Writes two bytes to memory.

§Arguments
  • address
  • value
Source

pub fn write_word(&mut self, address: u64, value: u32)

Writes four bytes to memory.

§Arguments
  • address
  • value
Source

pub fn write_doubleword(&mut self, address: u64, value: u64)

Writes eight bytes to memory.

§Arguments
  • address
  • value
Source

pub fn write_bytes(&mut self, address: u64, value: u64, width: u64)

Write multiple bytes to memory.

§Arguments
  • address
  • value
  • width up to eight
Source

pub fn validate_address(&self, address: u64) -> bool

Check if the address is valid memory address

§Arguments
  • address

Auto Trait Implementations§

§

impl Freeze for Memory

§

impl RefUnwindSafe for Memory

§

impl Send for Memory

§

impl Sync for Memory

§

impl Unpin for Memory

§

impl UnwindSafe for Memory

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.