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

Method read_cached

block-buffer/src/read.rs:82–90  ·  view source on GitHub ↗
(&mut self, len: usize)

Source from the content-addressed store, hash-verified

80 /// and sets the cursor position to `buffer.get_pos() + ret_len`.
81 #[inline(always)]
82 pub fn read_cached(&mut self, len: usize) -> &[u8] {
83 let rem = self.remaining();
84 let new_len = core::cmp::min(rem, len);
85 let pos = self.get_pos();
86
87 // SAFETY: `pos + new_len` is not equal to zero and not bigger than block size
88 unsafe { self.set_pos_unchecked(pos + new_len) };
89 &self.buffer[pos..][..new_len]
90 }
91
92 /// Write new block and consume `read_len` bytes from it.
93 ///

Callers 2

readMethod · 0.80
test_readFunction · 0.80

Calls 3

remainingMethod · 0.45
get_posMethod · 0.45
set_pos_uncheckedMethod · 0.45

Tested by 1

test_readFunction · 0.64