Function readAtLeast [src]
Use this function to increase their_end.
Prototype
pub fn readAtLeast(d: *Decoder, stream: *std.Io.Reader, their_amt: usize) !void
Parameters
d: *Decoder
stream: *std.Io.Reader
their_amt: usize
Source
pub fn readAtLeast(d: *Decoder, stream: *std.Io.Reader, their_amt: usize) !void {
assert(!d.disable_reads);
const existing_amt = d.cap - d.idx;
d.their_end = d.idx + their_amt;
if (their_amt <= existing_amt) return;
const request_amt = their_amt - existing_amt;
const dest = d.buf[d.cap..];
if (request_amt > dest.len) return error.TlsRecordOverflow;
stream.readSlice(dest[0..request_amt]) catch |err| switch (err) {
error.EndOfStream => return error.TlsConnectionTruncated,
error.ReadFailed => return error.ReadFailed,
};
d.cap += request_amt;
}