RamMemory

Struct RamMemory 

Source
pub struct RamMemory {
    pub data: Vec<u8>,
    pub write: bool,
}
Expand description

RAM memory.

Fields§

§data: Vec<u8>

RAM memory content.

§write: bool

If false the memory is read-only. Any attempt from the system to write data will return an MemoryAccessError::ReadOnly error.

Implementations§

Source§

impl RamMemory

Source

pub fn new_zero(size: usize) -> RamMemory

Creates a new RAM memory with size capacity, all bytes initialized to zero.

Source

pub fn new_from_value(size: usize, value: u8) -> RamMemory

Creates a new RAM memory with size capacity, all bytes initialized to value.

Source

pub fn new_from_slice(data: &[u8]) -> RamMemory

Creates a new RAM memory with data as initial content. The size of the created memory is the same as data.

Source

pub fn read_only(self) -> Self

Configure the memory as read-only.

Trait Implementations§

Source§

impl MemoryInterface for RamMemory

Source§

fn size(&self) -> u32

Source§

fn read_u8(&mut self, address: u32, _env: &mut Env) -> MemoryReadResult<u8>

Source§

fn write_u8( &mut self, address: u32, value: u8, _env: &mut Env, ) -> MemoryWriteResult

Source§

fn read_u16le(&mut self, address: u32, env: &mut Env) -> MemoryReadResult<u16>

Source§

fn write_u16le( &mut self, address: u32, value: u16, env: &mut Env, ) -> MemoryWriteResult

Source§

fn read_u32le(&mut self, address: u32, env: &mut Env) -> MemoryReadResult<u32>

Source§

fn write_u32le( &mut self, address: u32, value: u32, env: &mut Env, ) -> MemoryWriteResult

Source§

fn update(&mut self, _env: &mut Env)

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
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.