Reads and decompresses the local payload of this chunk. This returns `Cow`, so if no compression was used, it returns a direct reference to the mmap (Zero-Copy). If compressed, it allocates the decompressed buffer.
(&self)
| 870 | /// This returns `Cow`, so if no compression was used, it returns a direct reference |
| 871 | /// to the mmap (Zero-Copy). If compressed, it allocates the decompressed buffer. |
| 872 | pub fn read_raw(&self) -> Result<Cow<'a, [u8]>> { |
| 873 | let start = usize::try_from(self.offset) |
| 874 | .map_err(|_| ParcodeError::Format("Offset exceeds address space".into()))?; |
| 875 | let end = usize::try_from(self.payload_end_offset) |
| 876 | .map_err(|_| ParcodeError::Format("End offset exceeds address space".into()))?; |
| 877 | |
| 878 | // Access via self.reader.source (Deref to &[u8]) |
| 879 | let raw = self |
| 880 | .reader |
| 881 | .source |
| 882 | .get(start..end) |
| 883 | .ok_or_else(|| ParcodeError::Format("Payload out of bounds".into()))?; |
| 884 | let method_id = self.meta.compression_method(); |
| 885 | |
| 886 | self.reader.registry.get(method_id)?.decompress(raw) |
| 887 | } |
| 888 | |
| 889 | /// Returns a list of all direct child nodes. |
| 890 | /// |