Function readvAtLeast [src]
Receives TLS-encrypted data from stream, which must conform to StreamInterface.
Returns the number of bytes read, calling the underlying read function the
minimal number of times until the iovecs have at least len bytes filled.
If the number read is less than len it means the stream reached the end.
Reaching the end of the stream is not an error condition.
The iovecs parameter is mutable because this function needs to mutate the fields in
order to handle partial reads from the underlying stream layer.
Prototype
pub fn readvAtLeast(c: *Client, stream: anytype, iovecs: []std.posix.iovec, len: usize) !usize
Parameters
c: *Client
iovecs: []std.posix.iovec
len: usize
Source
pub fn readvAtLeast(c: *Client, stream: anytype, iovecs: []std.posix.iovec, len: usize) !usize {
if (c.eof()) return 0;
var off_i: usize = 0;
var vec_i: usize = 0;
while (true) {
var amt = try c.readvAdvanced(stream, iovecs[vec_i..]);
off_i += amt;
if (c.eof() or off_i >= len) return off_i;
while (amt >= iovecs[vec_i].len) {
amt -= iovecs[vec_i].len;
vec_i += 1;
}
iovecs[vec_i].base += amt;
iovecs[vec_i].len -= amt;
}
}