From de76815ebec2deead72f0ded8d24b0bb9586c2d8 Mon Sep 17 00:00:00 2001 From: Meghan Denny Date: Sat, 27 Jun 2026 19:11:17 -0700 Subject: [PATCH] AllocatingWriter: add anyWritable --- allocating_writer.zig | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/allocating_writer.zig b/allocating_writer.zig index 810011f25430e370132d5d4b9d5a0dfae61ecbc1..34b8241c331d69fad451f8e24eed0a65ca51a3d4 100644 --- a/allocating_writer.zig +++ b/allocating_writer.zig @@ -119,4 +119,17 @@ pub const AllocatingWriter = struct { for (iovec) |vec| self.appendAssumeCapacity(vec.base[0..vec.len]); return len; } + + pub fn anyWritable(self: *AllocatingWriter) nio.AnyWritable { + const S = struct { + fn write(s: *allowzero anyopaque, buffer: []const u8) anyerror!usize { + const bw: *AllocatingWriter = @ptrCast(@alignCast(s)); + return bw.write(buffer); + } + }; + return .{ + .vtable = &.{ .write = S.write }, + .state = @ptrCast(self), + }; + } }; -- 2.54.0