pub trait MemoryLike {
// Required methods
fn fits_memory(&self, offset: u64, len: u64) -> bool;
fn read_memory(&self, offset: u64, buffer: &mut [u8]);
fn read_memory_u8(&self, offset: u64) -> u8;
fn write_memory(&mut self, offset: u64, buffer: &[u8]);
}
Expand description
An abstraction over the memory of the smart contract.
Required Methods§
Sourcefn fits_memory(&self, offset: u64, len: u64) -> bool
fn fits_memory(&self, offset: u64, len: u64) -> bool
Returns whether the memory interval is completely inside the smart contract memory.
Sourcefn read_memory(&self, offset: u64, buffer: &mut [u8])
fn read_memory(&self, offset: u64, buffer: &mut [u8])
Reads the content of the given memory interval.
§Panics
If memory interval is outside the smart contract memory.
Sourcefn read_memory_u8(&self, offset: u64) -> u8
fn read_memory_u8(&self, offset: u64) -> u8
Sourcefn write_memory(&mut self, offset: u64, buffer: &[u8])
fn write_memory(&mut self, offset: u64, buffer: &[u8])
Writes the buffer into the smart contract memory.
§Panics
If offset + buffer.len()
is outside the smart contract memory.