mppf1
1
19496, "mppf", "I/O module: replace readstring/readbytes with readUtf8/readBytes/readData", "2022-03-18T15:10:46Z"
Today we have this:
proc channel.readstring(ref str_out: string, len: int(64) = -1) : bool throws
proc channel.readbytes(ref bytes_out: bytes, len: int(64) = -1) : bool throws
- read a given number of bytes from a channel into a string / bytes
- if the length is -1 then it reads until EOF
- Returns true if something was read, false upon EOF
- Issue [#13168] requests a version that can read into a pointer
Proposal:
proc reader.readUtf8(maxCodepoints: int = -1, maxBytes: int = -1) : string throws
proc reader.readBytes(maxBytes: int = -1) : bytes throws
proc reader.readData(data, maxBytes: int) : int throws
- All of these can read less than the max requested if there was some data and then an EOF (following Python)
- string/bytes returning functions return “” on EOF and use -1 to mean unlimited length (following Python)
- readData accepts same types as writeData and returns the number of bytes read or 0 on EOF
- These functions will ignore the channel’s Encoder
See also #19495 which proposes a similar change.