| author | |
| committer | |
| log | b85800a14c8dd942da21ad8765cd9c991c57b770 |
| tree | 7fe7cc853af5c772ca849026dc38dc75f9ddc97d |
| parent | d1b22241b2bc354b27c10a2bc42863030ec392df |
| signature |
6 files changed, 14 insertions(+), 0 deletions(-)
AnyReadable.zig+1| ... | @@ -29,6 +29,7 @@ pub const readExpected = R.readExpected; | ... | @@ -29,6 +29,7 @@ pub const readExpected = R.readExpected; |
| 29 | pub const readType = R.readType; | 29 | pub const readType = R.readType; |
| 30 | pub const skipBytes = R.skipBytes; | 30 | pub const skipBytes = R.skipBytes; |
| 31 | pub const skipUntilDelimiterOrEof = R.skipUntilDelimiterOrEof; | 31 | pub const skipUntilDelimiterOrEof = R.skipUntilDelimiterOrEof; |
| 32 | pub const pipeTo = R.pipeTo; | ||
| 32 | 33 | ||
| 33 | pub const Error = ReadError; // std compat | 34 | pub const Error = ReadError; // std compat |
| 34 | pub const ReadError = anyerror; | 35 | pub const ReadError = anyerror; |
buffered_reader.zig+1| ... | @@ -41,6 +41,7 @@ pub fn BufferedReader(comptime buffer_size: usize, comptime ReaderType: type) ty | ... | @@ -41,6 +41,7 @@ pub fn BufferedReader(comptime buffer_size: usize, comptime ReaderType: type) ty |
| 41 | pub const readType = R.readType; | 41 | pub const readType = R.readType; |
| 42 | pub const skipBytes = R.skipBytes; | 42 | pub const skipBytes = R.skipBytes; |
| 43 | pub const skipUntilDelimiterOrEof = R.skipUntilDelimiterOrEof; | 43 | pub const skipUntilDelimiterOrEof = R.skipUntilDelimiterOrEof; |
| 44 | pub const pipeTo = R.pipeTo; | ||
| 44 | 45 | ||
| 45 | pub const ReadError = extras.Pointee(ReaderType).ReadError; | 46 | pub const ReadError = extras.Pointee(ReaderType).ReadError; |
| 46 | pub fn read(self: *Self, dest: []u8) ReadError!usize { | 47 | pub fn read(self: *Self, dest: []u8) ReadError!usize { |
counting_reader.zig+1| ... | @@ -44,6 +44,7 @@ pub fn CountingReader(ReaderType: type) type { | ... | @@ -44,6 +44,7 @@ pub fn CountingReader(ReaderType: type) type { |
| 44 | pub const readType = R.readType; | 44 | pub const readType = R.readType; |
| 45 | pub const skipBytes = R.skipBytes; | 45 | pub const skipBytes = R.skipBytes; |
| 46 | pub const skipUntilDelimiterOrEof = R.skipUntilDelimiterOrEof; | 46 | pub const skipUntilDelimiterOrEof = R.skipUntilDelimiterOrEof; |
| 47 | pub const pipeTo = R.pipeTo; | ||
| 47 | 48 | ||
| 48 | pub const ReadError = extras.Pointee(ReaderType).ReadError; | 49 | pub const ReadError = extras.Pointee(ReaderType).ReadError; |
| 49 | 50 |
fixed_buffer_stream.zig+1| ... | @@ -49,6 +49,7 @@ pub fn FixedBufferStream(comptime Buffer: type) type { | ... | @@ -49,6 +49,7 @@ pub fn FixedBufferStream(comptime Buffer: type) type { |
| 49 | pub const readType = R.readType; | 49 | pub const readType = R.readType; |
| 50 | pub const skipBytes = R.skipBytes; | 50 | pub const skipBytes = R.skipBytes; |
| 51 | pub const skipUntilDelimiterOrEof = R.skipUntilDelimiterOrEof; | 51 | pub const skipUntilDelimiterOrEof = R.skipUntilDelimiterOrEof; |
| 52 | pub const pipeTo = R.pipeTo; | ||
| 52 | 53 | ||
| 53 | pub const ReadError = error{}; | 54 | pub const ReadError = error{}; |
| 54 | pub fn read(self: *Self, dest: []u8) ReadError!usize { | 55 | pub fn read(self: *Self, dest: []u8) ReadError!usize { |
limited_reader.zig+1| ... | @@ -44,6 +44,7 @@ pub fn LimitedReader(ReaderType: type) type { | ... | @@ -44,6 +44,7 @@ pub fn LimitedReader(ReaderType: type) type { |
| 44 | pub const readType = R.readType; | 44 | pub const readType = R.readType; |
| 45 | pub const skipBytes = R.skipBytes; | 45 | pub const skipBytes = R.skipBytes; |
| 46 | pub const skipUntilDelimiterOrEof = R.skipUntilDelimiterOrEof; | 46 | pub const skipUntilDelimiterOrEof = R.skipUntilDelimiterOrEof; |
| 47 | pub const pipeTo = R.pipeTo; | ||
| 47 | 48 | ||
| 48 | pub const ReadError = extras.Pointee(ReaderType).ReadError; | 49 | pub const ReadError = extras.Pointee(ReaderType).ReadError; |
| 49 | 50 |
nio.zig+9| ... | @@ -261,6 +261,15 @@ pub fn Readable(T: type, this_kind: enum { _var, _const, _bare }) type { | ... | @@ -261,6 +261,15 @@ pub fn Readable(T: type, this_kind: enum { _var, _const, _bare }) type { |
| 261 | if (byte == delimiter) return; | 261 | if (byte == delimiter) return; |
| 262 | } | 262 | } |
| 263 | } | 263 | } |
| 264 | |||
| 265 | pub fn pipeTo(self: Self, writer: anytype) !void { | ||
| 266 | var buf: [4096]u8 = undefined; | ||
| 267 | while (true) { | ||
| 268 | const n = try self.read(&buf); | ||
| 269 | if (n == 0) break; | ||
| 270 | try writer.writeAll(buf[0..n]); | ||
| 271 | } | ||
| 272 | } | ||
| 264 | }; | 273 | }; |
| 265 | } | 274 | } |
| 266 | 275 |