authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2026-05-31 22:21:42 -07:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2026-05-31 22:21:42 -07:00
log56210d17f2e3fb49e8eccf287aab1a76d09658a9
tree10629304e698f28336b97dc7bbb80b719af1fcdb
parent2a236f46f4a5831891d92469cc571b4215b3bff5
signaturebadge-check Signed by SSH key SHA256:4hHJbtBRU58AYXwjL7fkz2fnQHdiye8x1QpTCQ0sHNw

add readUntilDelimiter


6 files changed, 14 insertions(+), 0 deletions(-)

AnyReadable.zig+1
......@@ -23,6 +23,7 @@ pub const readUntilDelimitersArrayList = R.readUntilDelimitersArrayList;
2323pub const readAlloc = R.readAlloc;
2424pub const readInt = R.readInt;
2525pub const readUntilDelimitersAlloc = R.readUntilDelimitersAlloc;
26pub const readUntilDelimiter = R.readUntilDelimiter;
2627pub const readUntilDelimiterOrEof = R.readUntilDelimiterOrEof;
2728pub const readExpected = R.readExpected;
2829pub const skipBytes = R.skipBytes;
buffered_reader.zig+1
......@@ -35,6 +35,7 @@ pub fn BufferedReader(comptime buffer_size: usize, comptime ReaderType: type) ty
3535 pub const readAlloc = R.readAlloc;
3636 pub const readInt = R.readInt;
3737 pub const readUntilDelimitersAlloc = R.readUntilDelimitersAlloc;
38 pub const readUntilDelimiter = R.readUntilDelimiter;
3839 pub const readUntilDelimiterOrEof = R.readUntilDelimiterOrEof;
3940 pub const readExpected = R.readExpected;
4041 pub const skipBytes = R.skipBytes;
counting_reader.zig+1
......@@ -38,6 +38,7 @@ pub fn CountingReader(ReaderType: type) type {
3838 pub const readAlloc = R.readAlloc;
3939 pub const readInt = R.readInt;
4040 pub const readUntilDelimitersAlloc = R.readUntilDelimitersAlloc;
41 pub const readUntilDelimiter = R.readUntilDelimiter;
4142 pub const readUntilDelimiterOrEof = R.readUntilDelimiterOrEof;
4243 pub const readExpected = R.readExpected;
4344 pub const skipBytes = R.skipBytes;
fixed_buffer_stream.zig+1
......@@ -43,6 +43,7 @@ pub fn FixedBufferStream(comptime Buffer: type) type {
4343 pub const readAlloc = R.readAlloc;
4444 pub const readInt = R.readInt;
4545 pub const readUntilDelimitersAlloc = R.readUntilDelimitersAlloc;
46 pub const readUntilDelimiter = R.readUntilDelimiter;
4647 pub const readUntilDelimiterOrEof = R.readUntilDelimiterOrEof;
4748 pub const readExpected = R.readExpected;
4849 pub const skipBytes = R.skipBytes;
limited_reader.zig+1
......@@ -38,6 +38,7 @@ pub fn LimitedReader(ReaderType: type) type {
3838 pub const readAlloc = R.readAlloc;
3939 pub const readInt = R.readInt;
4040 pub const readUntilDelimitersAlloc = R.readUntilDelimitersAlloc;
41 pub const readUntilDelimiter = R.readUntilDelimiter;
4142 pub const readUntilDelimiterOrEof = R.readUntilDelimiterOrEof;
4243 pub const readExpected = R.readExpected;
4344 pub const skipBytes = R.skipBytes;
nio.zig+9
......@@ -182,6 +182,15 @@ pub fn Readable(T: type, this_kind: enum { _var, _const, _bare }) type {
182182 return list.toOwnedSlice();
183183 }
184184
185 pub fn readUntilDelimiter(self: Self, buf: []u8, needle: u8) ![]u8 {
186 for (buf, 0..) |*c, i| {
187 const b = try readByte(self);
188 c.* = b;
189 if (b == needle) return buf[0..i];
190 }
191 return error.StreamTooLong;
192 }
193
185194 /// Returned slice is not suffixed by needle but buf will contain it.
186195 pub fn readUntilDelimiterOrEof(self: Self, buf: []u8, needle: u8) !?[]u8 {
187196 for (buf, 0..) |*c, i| {