pub struct Memory {
pub values: Vec<Value>,
}Expand description
§A linear memory, freely addressable per word
The memory can be accessed from a script through the read and write
operators.
Aside from this, the stack is an important communication channel between
script and host. Please refer to Eval’s memory field for more
information on that.
§Constructing a Memory instance
By default, Memory has a size of 1024 words and is initially empty. This
is controlled by its Default implementation.
If you want to override this size, you can do so by overwriting the
values field with a Vec of the desired length.
Fields§
§values: Vec<Value>§The values in the memory
Implementations§
Source§impl Memory
impl Memory
Sourcepub fn read(&self, address: u32) -> Result<Value, InvalidAddress>
pub fn read(&self, address: u32) -> Result<Value, InvalidAddress>
§Read the value at the provided address
Sourcepub fn write(
&mut self,
address: u32,
value: Value,
) -> Result<(), InvalidAddress>
pub fn write( &mut self, address: u32, value: Value, ) -> Result<(), InvalidAddress>
§Write a value to an address
Sourcepub fn to_i32_slice(&self) -> &[i32]
pub fn to_i32_slice(&self) -> &[i32]
§Access the memory as a slice of i32 values
Sourcepub fn to_u32_slice(&self) -> &[u32]
pub fn to_u32_slice(&self) -> &[u32]
§Access the memory as a slice of u32 values
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Memory
impl RefUnwindSafe for Memory
impl Send for Memory
impl Sync for Memory
impl Unpin for Memory
impl UnsafeUnpin for Memory
impl UnwindSafe for Memory
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more