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), + }; + } };