Reads exactly `dst.len()` bytes starting at `addr`.
(&self, addr: usize, dst: &mut [u8])
| 127 | |
| 128 | /// Reads exactly `dst.len()` bytes starting at `addr`. |
| 129 | fn read_exact(&self, addr: usize, dst: &mut [u8]) -> Option<()> { |
| 130 | let end = addr.checked_add(dst.len())?; |
| 131 | if end > self.len() { |
| 132 | return None; |
| 133 | } |
| 134 | |
| 135 | let mut offset = 0; |
| 136 | while offset < dst.len() { |
| 137 | let read = self.read(addr + offset, &mut dst[offset..]); |
| 138 | if read == 0 { |
| 139 | return None; |
| 140 | } |
| 141 | offset += read; |
| 142 | } |
| 143 | |
| 144 | Some(()) |
| 145 | } |
| 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>> { |
no test coverage detected