authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2026-05-22 13:50:56 -07:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2026-05-22 13:50:56 -07:00
log62170a7ffee9a771bc71c52179e6ae7daa5ea11b
tree9fce29a9bc301b62b793705fed5d27ecfe0c4a6c
parent6e828b498ea16af2d52b62922d18d868e1b85d2b
signaturebadge-check Signed by SSH key SHA256:4hHJbtBRU58AYXwjL7fkz2fnQHdiye8x1QpTCQ0sHNw

CountingWriter: add writev


1 files changed, 11 insertions(+), 0 deletions(-)

counting_writer.zig+11
...@@ -1,7 +1,13 @@...@@ -1,7 +1,13 @@
1const std = @import("std");1const std = @import("std");
2const builtin = @import("builtin");
2const extras = @import("extras");3const extras = @import("extras");
3const nio = @import("./nio.zig");4const nio = @import("./nio.zig");
45
6const sys = switch (builtin.target.os.tag) {
7 .linux => @import("sys-linux"),
8 else => unreachable,
9};
10
5pub fn CountingWriter(WriterType: type) type {11pub fn CountingWriter(WriterType: type) type {
6 return struct {12 return struct {
7 backing_writer: WriterType,13 backing_writer: WriterType,
...@@ -32,5 +38,10 @@ pub fn CountingWriter(WriterType: type) type {...@@ -32,5 +38,10 @@ pub fn CountingWriter(WriterType: type) type {
32 self.bytes_written += len;38 self.bytes_written += len;
33 return len;39 return len;
34 }40 }
41 pub fn writev(self: *Self, iovec: []const sys.struct_iovec) WriteError!usize {
42 const len = try self.backing_writer.writev(iovec);
43 self.bytes_written += len;
44 return len;
45 }
35 };46 };
36}47}