| ... | @@ -43,5 +43,18 @@ pub fn CountingWriter(WriterType: type) type { | ... | @@ -43,5 +43,18 @@ pub fn CountingWriter(WriterType: type) type { |
| 43 | self.bytes_written += len; | 43 | self.bytes_written += len; |
| 44 | return len; | 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 | } |