I need to read a complicated binary file that contains data to be parsed into multiple structs:
fn readComplicatedOne(reader: anytype) ComplicatedStruct {
reader.read(); //...
return .{...};
}
fn readComplicatedTwo(reader: anytype) ComplicatedStruct2 {
reader.read(); //...
return .{...};
}
test "read file" {
const file = try std.fs.cwd().openFile("my_file.bin", .{ .mode = std.fs.File.OpenMode.read_only });
const p1 = read()
var reader = file.reader();
readComplicatedOne(&reader);
readComplicatedTwo(&reader);
}
this works, but while writing the "readComplicated" functions, I dont have any help from the language server. I know that reader is some kind of GenericReader(A, B), but I dont know how to write that in the readComplicated* function definitions.
Is there a way to write the read functions signatures in a way I get code completions (functions, signatures, return types) for the reader: GenericReader parameter?