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 an error.InvalidValue
. TODO optimization taking advantage of most fields being in order