MCPcopy Create free account
hub / github.com/RetypeOS/parcode / read_raw

Method read_raw

src/reader.rs:872–887  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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 ///

Callers 14

get_lazyMethod · 0.80
loadMethod · 0.80
getMethod · 0.80
ensure_shard_loadedMethod · 0.80
from_nodeMethod · 0.80
decodeMethod · 0.80
lenMethod · 0.80
locate_shard_itemMethod · 0.80
getMethod · 0.80
iterMethod · 0.80

Calls 3

compression_methodMethod · 0.80
decompressMethod · 0.80
getMethod · 0.45

Tested by 1

analyze_payloadMethod · 0.64