| author | |
| committer | |
| log | aa1eefacf29df6ef27a486a13f46ff9773b1eac0 |
| tree | ff686287c67ed5f3acc72b9295f830b7a26a26c8 |
| parent | 78a74ffaa65b527d0cf4303e4387071dd27cad14 |
| signature |
1 files changed, 13 insertions(+), 0 deletions(-)
counting_writer.zig+13| ... | ... | @@ -43,5 +43,18 @@ pub fn CountingWriter(WriterType: type) type { |
| 43 | 43 | self.bytes_written += len; |
| 44 | 44 | return len; |
| 45 | 45 | } |
| 46 | ||
| 47 | pub fn anyWritable(self: *Self) nio.AnyWritable { | |
| 48 | const S = struct { | |
| 49 | fn write(s: *allowzero anyopaque, buffer: []const u8) anyerror!usize { | |
| 50 | const cw: *Self = @ptrCast(@alignCast(s)); | |
| 51 | return cw.write(buffer); | |
| 52 | } | |
| 53 | }; | |
| 54 | return .{ | |
| 55 | .vtable = &.{ .write = S.write }, | |
| 56 | .state = @ptrCast(self), | |
| 57 | }; | |
| 58 | } | |
| 46 | 59 | }; |
| 47 | 60 | } |