View the bytes as a `&[u8]`. Zero-copy for both variants: `Heap` derefs the `Arc<[u8]>`; `Mmap` slices the mapping.
(&self)
| 68 | impl BytesSource { |
| 69 | /// View the bytes as a `&[u8]`. Zero-copy for both variants: |
| 70 | /// `Heap` derefs the `Arc<[u8]>`; `Mmap` slices the mapping. |
| 71 | pub fn as_slice(&self) -> &[u8] { |
| 72 | match self { |
| 73 | BytesSource::Heap(arc) => arc, |
| 74 | BytesSource::Mmap { mmap, offset, len } => &mmap[*offset..*offset + *len], |
| 75 | } |
| 76 | } |
| 77 | } |
| 78 |
no outgoing calls