Function peekSentinel [src]

Returns a slice of the next bytes of buffered data from the stream until sentinel is found, without advancing the seek position. Returned slice has a sentinel; end of stream does not count as a delimiter. Invalidates previously returned values from peek. See also: takeSentinel peekDelimiterExclusive peekDelimiterInclusive

Prototype

pub fn peekSentinel(r: *Reader, comptime sentinel: u8) DelimiterError![:sentinel]u8

Parameters

r: *Readersentinel: u8

Possible Errors

EndOfStream

For "inclusive" functions, stream ended before the delimiter was found. For "exclusive" functions, stream ended and there are no more bytes to return.

ReadFailed

See the Reader implementation for detailed diagnostics.

StreamTooLong

The delimiter was not found within a number of bytes matching the capacity of the Reader.

Example

test peekSentinel { var r: Reader = .fixed("ab\nc"); try testing.expectEqualStrings("ab", try r.peekSentinel('\n')); try testing.expectEqualStrings("ab", try r.peekSentinel('\n')); }

Source

pub fn peekSentinel(r: *Reader, comptime sentinel: u8) DelimiterError![:sentinel]u8 { const result = try r.peekDelimiterInclusive(sentinel); return result[0 .. result.len - 1 :sentinel]; }