See Streams.Buffer for convenience API to obtain the streams parameter.
pub fn init(mr: *MultiReader, gpa: Allocator, io: Io, streams: *Streams, files: []const File) void
pub fn init(mr: *MultiReader, gpa: Allocator, io: Io, streams: *Streams, files: []const File) void {
const contexts = streams.contexts();
for (contexts, files) |*context, file| context.* = .{
.mr = mr,
.fr = .{
.io = io,
.file = file,
.mode = .streaming,
.interface = .{
.vtable = &.{
.stream = stream,
.discard = discard,
.readVec = readVec,
.rebase = rebase,
},
.buffer = &.{},
.seek = 0,
.end = 0,
},
},
.vec = .{&.{}},
.err = null,
};
mr.* = .{
.gpa = gpa,
.streams = streams,
.batch = .init(streams.storage()),
};
for (contexts, 0..) |*context, i| {
const r = &context.fr.interface;
rebaseGrowing(mr, context, 1) catch |err| {
context.err = err;
continue;
};
context.vec[0] = r.buffer;
mr.batch.addAt(@intCast(i), .{ .file_read_streaming = .{
.file = context.fr.file,
.data = &context.vec,
} });
}
}