Function consume [src]
Removes the first n bytes from buffer by 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.drain function implementations to implement partial
drains.
Prototype
pub fn consume(w: *Writer, n: usize) usize
Parameters
w: *Writer
n: usize
Source
pub 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;
}