DoxigAlpha

isBytes

Reads slice.len bytes from the stream and returns if they are the same as the passed slice

Function parameters

Parameters

#
slice:[]const u8

Optional parameters for `skipBytes`

Types

#
SkipBytesOptions
Optional parameters for `skipBytes`

Returns the number of bytes read.

Functions

#
read
Returns the number of bytes read.
readAll
Returns the number of bytes read.
readAtLeast
Returns the number of bytes read, calling the underlying read
readNoEof
If the number read would be smaller than `buf.len`, `error.EndOfStream` is returned instead.
readAllArrayList
Appends to the `std.array_list.Managed` contents by reading from the stream
readAllAlloc
Allocates enough memory to hold all the contents of the stream.
readUntilDelimiterArrayList
Deprecated: use `streamUntilDelimiter` with ArrayList's writer instead.
readUntilDelimiterAlloc
Deprecated: use `streamUntilDelimiter` with ArrayList's writer instead.
readUntilDelimiter
Deprecated: use `streamUntilDelimiter` with FixedBufferStream's writer instead.
readUntilDelimiterOrEofAlloc
Deprecated: use `streamUntilDelimiter` with ArrayList's (or any other's) writer instead.
readUntilDelimiterOrEof
Deprecated: use `streamUntilDelimiter` with FixedBufferStream's writer instead.
streamUntilDelimiter
Appends to the `writer` contents by reading from the stream until `delimiter` is found.
skipUntilDelimiterOrEof
Reads from the stream until specified byte is found, discarding all data,
readByte
Reads 1 byte from the stream or returns `error.EndOfStream`.
readByteSigned
Same as `readByte` except the returned byte is signed.
readBytesNoEof
Reads exactly `num_bytes` bytes and returns as an array.
skipBytes
Reads `num_bytes` bytes from the stream and discards them
isBytes
Reads `slice.len` bytes from the stream and returns if they are the same as the passed slice
readEnum
Reads an integer with the same size as the given enum's tag type.
discard
Reads the stream until the end, ignoring all the data.
adaptToNewApi
Helper for bridging to the new `Reader` API while upgrading.

Source

Implementation

#
pub fn isBytes(self: Self, slice: []const u8) anyerror!bool {
    var i: usize = 0;
    var matches = true;
    while (i < slice.len) : (i += 1) {
        if (slice[i] != try self.readByte()) {
            matches = false;
        }
    }
    return matches;
}