Function readLastAssumeLength [src]
Reads last length bytes written to the ring buffer into dest;
Asserts that length not greater than ring buffer or dest length
Uses memcpy and so dest must not overlap ring buffer data.
Reduces write index by length.
Prototype
pub fn readLastAssumeLength(self: *RingBuffer, dest: []u8, length: usize) void
Parameters
self: *RingBuffer
dest: []u8
length: usize
Source
pub fn readLastAssumeLength(self: *RingBuffer, dest: []u8, length: usize) void {
assert(length <= self.len() and length <= dest.len);
const slice = self.sliceLast(length);
slice.copyTo(dest);
self.write_index = if (self.write_index >= self.data.len)
self.write_index - length
else
self.mask(self.write_index + self.data.len - length);
}