Transfers bytes to the stream, calling drain at most once.
Returns the number of bytes transferred, which may be less than
bytes.len, including zero.
A return value less than bytes.len does not indicate failure; a
subsequent call may return nonzero, or fail with error.WriteFailed.
See also:
writeAllwriteVecpub fn write(w: *Writer, bytes: []const u8) Error!usize
pub fn write(w: *Writer, bytes: []const u8) Error!usize {
if (w.end + bytes.len <= w.buffer.len) {
@branchHint(.likely);
@memcpy(w.buffer[w.end..][0..bytes.len], bytes);
w.end += bytes.len;
return bytes.len;
}
return w.vtable.drain(w, &.{bytes}, 1);
}