Function takeDelimiterInclusive [src]
Returns a slice of the next bytes of buffered data from the stream until
delimiter is found, advancing the seek position.
Returned slice includes the delimiter as the last byte.
Invalidates previously returned values from peek.
See also:
takeSentinel
takeDelimiterExclusive
peekDelimiterInclusive
Prototype
pub fn takeDelimiterInclusive(r: *Reader, delimiter: u8) DelimiterError![]u8
Parameters
r: *Reader
delimiter: u8
Possible Errors
For "inclusive" functions, stream ended before the delimiter was found. For "exclusive" functions, stream ended and there are no more bytes to return.
See the Reader
implementation for detailed diagnostics.
The delimiter was not found within a number of bytes matching the
capacity of the Reader
.
Example
test takeDelimiterInclusive {
var r: Reader = .fixed("ab\nc");
try testing.expectEqualStrings("ab\n", try r.takeDelimiterInclusive('\n'));
try testing.expectError(error.EndOfStream, r.takeDelimiterInclusive('\n'));
}
Source
pub fn takeDelimiterInclusive(r: *Reader, delimiter: u8) DelimiterError![]u8 {
const result = try r.peekDelimiterInclusive(delimiter);
r.toss(result.len);
return result;
}