| ... | ... | @@ -1,5 +1,12 @@ |
| 1 | 1 | const std = @import("std"); |
| 2 | 2 | const nio = @import("./nio.zig"); |
| 3 | const builtin = @import("builtin"); |
| 4 | const sys_linux = @import("sys-linux"); |
| 5 | |
| 6 | const sys = switch (builtin.target.os.tag) { |
| 7 | .linux => sys_linux, |
| 8 | else => unreachable, |
| 9 | }; |
| 3 | 10 | |
| 4 | 11 | pub fn BufferedWriter(comptime buffer_size: usize, comptime WriterType: type) type { |
| 5 | 12 | return struct { |
| ... | ... | @@ -29,6 +36,15 @@ pub fn BufferedWriter(comptime buffer_size: usize, comptime WriterType: type) ty |
| 29 | 36 | self.end = new_end; |
| 30 | 37 | return bytes.len; |
| 31 | 38 | } |
| 39 | pub fn writev(self: *Self, iovec: []const sys.struct_iovec) WriteError!usize { |
| 40 | var total: usize = 0; |
| 41 | for (iovec) |vec| { |
| 42 | const len = try write(self, vec.base[0..vec.len]); |
| 43 | total += len; |
| 44 | if (len != vec.len) break; |
| 45 | } |
| 46 | return total; |
| 47 | } |
| 32 | 48 | |
| 33 | 49 | pub fn anyWritable(self: *Self) nio.AnyWritable { |
| 34 | 50 | const S = struct { |