pub inline fn takeStruct(r: *Reader, comptime T: type, endian: std.builtin.Endian) Error!T ReadFailedSee the Reader implementation for detailed diagnostics.
EndOfStream1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239pub inline fn takeStruct(r: *Reader, comptime T: type, endian: std.builtin.Endian) Error!T {
switch (@typeInfo(T)) {
.@"struct" => |info| switch (info.layout) {
.auto => @compileError("ill-defined memory layout"),
.@"extern" => {
var res: T = undefined;
try r.readSliceEndian(T, (&res)[0..1], endian);
return res;
},
.@"packed" => {
return @bitCast(try takeInt(r, info.backing_integer.?, endian));
},
},
else => @compileError("not a struct"),
}
}