| 189 | |
| 190 | #[inline(always)] |
| 191 | fn write_all(&mut self, addr: usize, src: &[u8]) -> Option<()> { |
| 192 | let end = self.checked_end(addr, src.len())?; |
| 193 | let mut pos = addr; |
| 194 | let mut src_offset = 0; |
| 195 | |
| 196 | while pos < end { |
| 197 | let chunk_idx = pos >> self.chunk_shift; |
| 198 | let chunk_offset = pos & self.chunk_mask; |
| 199 | let copy_len = min(self.chunk_size - chunk_offset, end - pos); |
| 200 | |
| 201 | let chunk = self.chunk_mut(chunk_idx).ok()?; |
| 202 | chunk[chunk_offset..chunk_offset + copy_len].copy_from_slice(&src[src_offset..src_offset + copy_len]); |
| 203 | |
| 204 | pos += copy_len; |
| 205 | src_offset += copy_len; |
| 206 | } |
| 207 | |
| 208 | Some(()) |
| 209 | } |
| 210 | |
| 211 | #[inline(always)] |
| 212 | fn fill(&mut self, addr: usize, len: usize, val: u8) -> Option<()> { |