Reads `len` bytes starting at `addr` into a newly allocated buffer.
(&self, addr: usize, len: usize)
| 146 | |
| 147 | /// Reads `len` bytes starting at `addr` into a newly allocated buffer. |
| 148 | fn read_vec(&self, addr: usize, len: usize) -> Option<Vec<u8>> { |
| 149 | let end = addr.checked_add(len)?; |
| 150 | if end > self.len() { |
| 151 | return None; |
| 152 | } |
| 153 | |
| 154 | let mut data = vec![0; len]; |
| 155 | self.read_exact(addr, &mut data)?; |
| 156 | Some(data) |
| 157 | } |
| 158 | |
| 159 | /// Reads exactly 1 byte at the effective address `base + offset`. |
| 160 | fn read_8(&self, base: u64, offset: u64) -> core::result::Result<u8, crate::Trap> { |