pub fn readVec(r: *Reader, data: [][]u8) Error!usize r: *Readerdata: [][]u8ReadFailedSee the Reader implementation for detailed diagnostics.
EndOfStream420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442pub fn readVec(r: *Reader, data: [][]u8) Error!usize {
var seek = r.seek;
for (data, 0..) |buf, i| {
const contents = r.buffer[seek..r.end];
const copy_len = @min(contents.len, buf.len);
@memcpy(buf[0..copy_len], contents[0..copy_len]);
seek += copy_len;
if (buf.len - copy_len == 0) continue;
// All of `buffer` has been copied to `data`.
const n = seek - r.seek;
r.seek = seek;
data[i] = buf[copy_len..];
defer data[i] = buf;
return n + (r.vtable.readVec(r, data[i..]) catch |err| switch (err) {
error.EndOfStream => if (n == 0) return error.EndOfStream else 0,
error.ReadFailed => |e| return e,
});
}
const n = seek - r.seek;
r.seek = seek;
return n;
}
Writes bytes from the internally tracked stream position to
data.Returns the number of bytes written, which will be at minimum
0and at most the sum of each data slice length. The number of bytes read, including zero, does not indicate end of stream.The reader's internal logical seek position moves forward in accordance with the number of bytes returned from this function.