Reads an integer with the same size as the given enum's tag type. If the
integer matches an enum tag, casts the integer to the enum tag and returns
it. Otherwise, returns error.InvalidEnumTag.
Asserts the buffer was initialized with a capacity at least @sizeOf(Enum).
pub fn takeEnum(r: *Reader, comptime Enum: type, endian: std.builtin.Endian) TakeEnumError!Enum
pub fn takeEnum(r: *Reader, comptime Enum: type, endian: std.builtin.Endian) TakeEnumError!Enum {
const Tag = @typeInfo(Enum).@"enum".tag_type;
const int = try r.takeInt(Tag, endian);
return std.enums.fromInt(Enum, int) orelse return error.InvalidEnumTag;
}