pub fn consume(w: *Writer, n: usize) usize w: *Writern: usize2405
2406
2407
2408
2409
2410
2411
2412
2413
2414pub fn consume(w: *Writer, n: usize) usize {
if (n < w.end) {
const remaining = w.buffer[n..w.end];
@memmove(w.buffer[0..remaining.len], remaining);
w.end = remaining.len;
return 0;
}
defer w.end = 0;
return n - w.end;
}
Removes the first
nbytes frombufferby shifting buffer contents, returning how many bytes are left after consuming the entire buffer, or zero if the entire buffer was not consumed.Useful for
VTable.drainfunction implementations to implement partial drains.