MCPcopy Create free account
hub / github.com/RustCrypto/utils / read

Method read

block-buffer/src/read.rs:137–150  ·  view source on GitHub ↗
(&mut self, buf: &mut [u8], mut gen_block: impl FnMut(&mut Array<u8, BS>))

Source from the content-addressed store, hash-verified

135 /// from the last generated block into the buffer for future use.
136 #[inline]
137 pub fn read(&mut self, buf: &mut [u8], mut gen_block: impl FnMut(&mut Array<u8, BS>)) {
138 let head_ks = self.read_cached(buf.len());
139 let (head, buf) = buf.split_at_mut(head_ks.len());
140 let (blocks, tail) = Array::slice_as_chunks_mut(buf);
141
142 head.copy_from_slice(head_ks);
143 for block in blocks {
144 gen_block(block);
145 }
146
147 self.write_block(tail.len(), gen_block, |tail_ks| {
148 tail.copy_from_slice(tail_ks);
149 });
150 }
151
152 /// Serialize buffer into a byte array.
153 #[inline]

Callers

nothing calls this directly

Calls 4

slice_as_chunks_mutFunction · 0.85
read_cachedMethod · 0.80
lenMethod · 0.80
write_blockMethod · 0.80

Tested by

no test coverage detected