readUntilDelimiter
Deprecated: use streamUntilDelimiter with FixedBufferStream's writer instead.
Reads from the stream until specified byte is found. If the buffer is not
large enough to hold the entire contents, error.StreamTooLong is returned.
If end-of-stream is found, error.EndOfStream is returned.
Returns a slice of the stream data, with ptr equal to buf.ptr. The
delimiter byte is written to the output buffer but is not included
in the returned slice.
Function parameters
Parameters
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 readUntilDelimiter(self: Self, buf: []u8, delimiter: u8) anyerror![]u8 {
var fbs = std.io.fixedBufferStream(buf);
try self.streamUntilDelimiter(fbs.writer(), delimiter, fbs.buffer.len);
const output = fbs.getWritten();
buf[output.len] = delimiter; // emulating old behaviour
return output;
}