I have a function that calls reader.adaptToOldInterface().readAllAlloc(allocator, std.math.maxInt(usize)); on a readerStreaming that was obtained from a stdin which is in raw mode. How to I replicate readAllAllocs behavior using purely the new API?
I posted this question already but only got the answer for something else I didn’t know and then the thread went silent. I renamed it to the question that was then answered, so that if anyone else has that other question they can find it.
So I guess that readAllAlloc no longer has a direct equivalent?
I tried to use streamRemaining and allocRemaining and stream into an allocating reader or just return the bytes but that just read once and then somehow broke the reader in the next iteration, because after the first read it would only return 0 bytes. I find this strange because I dont see just from its documentation how it would behave differently to readAllAlloc
var buf: [256]u8 = undefined;
var len = buf.len;
while (len == buf.len) {
len = try self.stdin.readSliceShort(&buf);
try bytes.writer.writeAll(buf[0..len]);
}
If you feel like it id be interested in a little code review or basic opinion, because Im a student and so far havent worked professionally
This runs on 0.15.1 and just zig build run reproduces it on ghostty. The issue is that input doesnt work unless uncommenting the marked line. The interesting function is in Tty.zig