| ... | @@ -108,10 +108,11 @@ pub fn Readable(T: type, this_kind: enum { _var, _const, _bare }) type { | ... | @@ -108,10 +108,11 @@ pub fn Readable(T: type, this_kind: enum { _var, _const, _bare }) type { |
| 108 | return error.StreamTooLong; | 108 | return error.StreamTooLong; |
| 109 | } | 109 | } |
| 110 | | 110 | |
| 111 | pub fn readUntilDelimitersArrayList(self: Self, array_list: *std.ArrayList(u8), needle: []const u8, max_size: usize) !usize { | 111 | pub fn readUntilDelimitersArrayList(self: Self, array_list: *std.ArrayList(u8), needle: []const u8, max_size: usize) ![]u8 { |
| | 112 | const initial_len = array_list.items.len; |
| 112 | for (0..max_size) |i| { | 113 | for (0..max_size) |i| { |
| 113 | try array_list.append(try readByte(self)); | 114 | try array_list.append(try readByte(self)); |
| 114 | if (std.mem.endsWith(u8, array_list.items, needle)) return i + 1 - needle.len; | 115 | if (std.mem.endsWith(u8, array_list.items, needle)) return array_list.items[initial_len..][0 .. i + 1 - needle.len]; |
| 115 | } | 116 | } |
| 116 | return error.StreamTooLong; | 117 | return error.StreamTooLong; |
| 117 | } | 118 | } |