Writes all bytes in `src` starting at `addr`, or returns `None` if any byte could not be written.
(&mut self, addr: usize, src: &[u8])
| 53 | |
| 54 | /// Writes all bytes in `src` starting at `addr`, or returns `None` if any byte could not be written. |
| 55 | fn write_all(&mut self, addr: usize, src: &[u8]) -> Option<()> { |
| 56 | let end = addr.checked_add(src.len())?; |
| 57 | if end > self.len() { |
| 58 | return None; |
| 59 | } |
| 60 | |
| 61 | let mut offset = 0; |
| 62 | while offset < src.len() { |
| 63 | let written = self.write(addr + offset, &src[offset..]); |
| 64 | if written == 0 { |
| 65 | return None; |
| 66 | } |
| 67 | offset += written; |
| 68 | } |
| 69 | |
| 70 | Some(()) |
| 71 | } |
| 72 | |
| 73 | /// Fills the range `[addr, addr + len)` with `val`. |
| 74 | fn fill(&mut self, addr: usize, len: usize, val: u8) -> Option<()> { |
no test coverage detected