From aa1eefacf29df6ef27a486a13f46ff9773b1eac0 Mon Sep 17 00:00:00 2001 From: Meghan Denny Date: Tue, 26 May 2026 20:31:21 -0700 Subject: [PATCH] CountingWriter: add anyWritable --- counting_writer.zig | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/counting_writer.zig b/counting_writer.zig index d54a35318fc41e62b1b85e0d7ca171bba947fa19..a17393254e9b41c0536e57b7d4b8be54b5b2e36b 100644 --- a/counting_writer.zig +++ b/counting_writer.zig @@ -43,5 +43,18 @@ pub fn CountingWriter(WriterType: type) type { self.bytes_written += len; return len; } + + pub fn anyWritable(self: *Self) nio.AnyWritable { + const S = struct { + fn write(s: *allowzero anyopaque, buffer: []const u8) anyerror!usize { + const cw: *Self = @ptrCast(@alignCast(s)); + return cw.write(buffer); + } + }; + return .{ + .vtable = &.{ .write = S.write }, + .state = @ptrCast(self), + }; + } }; } -- 2.54.0