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;...@@ -23,6 +23,7 @@ pub const readUntilDelimitersArrayList = R.readUntilDelimitersArrayList;
23pub const readAlloc = R.readAlloc;23pub const readAlloc = R.readAlloc;
24pub const readInt = R.readInt;24pub const readInt = R.readInt;
25pub const readUntilDelimitersAlloc = R.readUntilDelimitersAlloc;25pub const readUntilDelimitersAlloc = R.readUntilDelimitersAlloc;
26pub const readUntilDelimiter = R.readUntilDelimiter;
26pub const readUntilDelimiterOrEof = R.readUntilDelimiterOrEof;27pub const readUntilDelimiterOrEof = R.readUntilDelimiterOrEof;
27pub const readExpected = R.readExpected;28pub const readExpected = R.readExpected;
28pub const skipBytes = R.skipBytes;29pub const skipBytes = R.skipBytes;
buffered_reader.zig+1
...@@ -35,6 +35,7 @@ pub fn BufferedReader(comptime buffer_size: usize, comptime ReaderType: type) ty...@@ -35,6 +35,7 @@ pub fn BufferedReader(comptime buffer_size: usize, comptime ReaderType: type) ty
35 pub const readAlloc = R.readAlloc;35 pub const readAlloc = R.readAlloc;
36 pub const readInt = R.readInt;36 pub const readInt = R.readInt;
37 pub const readUntilDelimitersAlloc = R.readUntilDelimitersAlloc;37 pub const readUntilDelimitersAlloc = R.readUntilDelimitersAlloc;
38 pub const readUntilDelimiter = R.readUntilDelimiter;
38 pub const readUntilDelimiterOrEof = R.readUntilDelimiterOrEof;39 pub const readUntilDelimiterOrEof = R.readUntilDelimiterOrEof;
39 pub const readExpected = R.readExpected;40 pub const readExpected = R.readExpected;
40 pub const skipBytes = R.skipBytes;41 pub const skipBytes = R.skipBytes;
counting_reader.zig+1
...@@ -38,6 +38,7 @@ pub fn CountingReader(ReaderType: type) type {...@@ -38,6 +38,7 @@ pub fn CountingReader(ReaderType: type) type {
38 pub const readAlloc = R.readAlloc;38 pub const readAlloc = R.readAlloc;
39 pub const readInt = R.readInt;39 pub const readInt = R.readInt;
40 pub const readUntilDelimitersAlloc = R.readUntilDelimitersAlloc;40 pub const readUntilDelimitersAlloc = R.readUntilDelimitersAlloc;
41 pub const readUntilDelimiter = R.readUntilDelimiter;
41 pub const readUntilDelimiterOrEof = R.readUntilDelimiterOrEof;42 pub const readUntilDelimiterOrEof = R.readUntilDelimiterOrEof;
42 pub const readExpected = R.readExpected;43 pub const readExpected = R.readExpected;
43 pub const skipBytes = R.skipBytes;44 pub const skipBytes = R.skipBytes;
fixed_buffer_stream.zig+1
...@@ -43,6 +43,7 @@ pub fn FixedBufferStream(comptime Buffer: type) type {...@@ -43,6 +43,7 @@ pub fn FixedBufferStream(comptime Buffer: type) type {
43 pub const readAlloc = R.readAlloc;43 pub const readAlloc = R.readAlloc;
44 pub const readInt = R.readInt;44 pub const readInt = R.readInt;
45 pub const readUntilDelimitersAlloc = R.readUntilDelimitersAlloc;45 pub const readUntilDelimitersAlloc = R.readUntilDelimitersAlloc;
46 pub const readUntilDelimiter = R.readUntilDelimiter;
46 pub const readUntilDelimiterOrEof = R.readUntilDelimiterOrEof;47 pub const readUntilDelimiterOrEof = R.readUntilDelimiterOrEof;
47 pub const readExpected = R.readExpected;48 pub const readExpected = R.readExpected;
48 pub const skipBytes = R.skipBytes;49 pub const skipBytes = R.skipBytes;
limited_reader.zig+1
...@@ -38,6 +38,7 @@ pub fn LimitedReader(ReaderType: type) type {...@@ -38,6 +38,7 @@ pub fn LimitedReader(ReaderType: type) type {
38 pub const readAlloc = R.readAlloc;38 pub const readAlloc = R.readAlloc;
39 pub const readInt = R.readInt;39 pub const readInt = R.readInt;
40 pub const readUntilDelimitersAlloc = R.readUntilDelimitersAlloc;40 pub const readUntilDelimitersAlloc = R.readUntilDelimitersAlloc;
41 pub const readUntilDelimiter = R.readUntilDelimiter;
41 pub const readUntilDelimiterOrEof = R.readUntilDelimiterOrEof;42 pub const readUntilDelimiterOrEof = R.readUntilDelimiterOrEof;
42 pub const readExpected = R.readExpected;43 pub const readExpected = R.readExpected;
43 pub const skipBytes = R.skipBytes;44 pub const skipBytes = R.skipBytes;
nio.zig+9
...@@ -182,6 +182,15 @@ pub fn Readable(T: type, this_kind: enum { _var, _const, _bare }) type {...@@ -182,6 +182,15 @@ pub fn Readable(T: type, this_kind: enum { _var, _const, _bare }) type {
182 return list.toOwnedSlice();182 return list.toOwnedSlice();
183 }183 }
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
185 /// Returned slice is not suffixed by needle but buf will contain it.194 /// Returned slice is not suffixed by needle but buf will contain it.
186 pub fn readUntilDelimiterOrEof(self: Self, buf: []u8, needle: u8) !?[]u8 {195 pub fn readUntilDelimiterOrEof(self: Self, buf: []u8, needle: u8) !?[]u8 {
187 for (buf, 0..) |*c, i| {196 for (buf, 0..) |*c, i| {