func parseBinaryStruct(ann []Symbol, lengthByte byte, r io.Reader) (Value, error) {
	if lengthByte == 0 {
		return Struct{annotations: ann, fields: []StructField{}}, nil
	}

	var numBytes uint32
	var errLength error
	// "When L is 1, the struct has at least one symbol/value pair, the length
	// field exists, and the field name integers are sorted in increasing order."
	if lengthByte == 1 {
		numBytes, errLength = readVarUInt32(r)
	} else {
		numBytes, errLength = determineLength32(lengthByte, r)
	}

	if errLength != nil {
		return nil, errors.WithMessage(errLength, "unable to parse length of struct")
	}

	data := make([]byte, numBytes)
	if n, err := r.Read(data); err != nil || n != int(numBytes) {
		return nil, errors.Errorf("unable to read struct - read %d bytes of %d with err: %v", n, numBytes, err)
	}

	// Not having any fields isn't the same as being null, so differentiate
	// between the two by ensuring that fields isn't nil even if it's empty.
	fields := []StructField{}
	dataReader := bytes.NewReader(data)
	for dataReader.Len() > 0 {
		symbol, errSymbol := readVarUInt32(dataReader)
		if errSymbol != nil {
			return nil, errors.WithMessage(errSymbol, "unable to read struct field symbol")
		}
		value, errValue := parseNextBinaryValue(nil, dataReader)
		if errValue != nil {
			return nil, errors.WithMessage(errValue, "unable to read struct field value")
		}

		// Ignore padding.
		if value.Type() == TypePadding {
			continue
		}

		fields = append(fields, StructField{
			Symbol: Symbol{id: int32(symbol)},
			Value:  value,
		})
	}

	return Struct{annotations: ann, fields: fields}, nil
}
// parseBinaryStruct reads all of the symbol / value pairs and puts them
// into a Struct.
parseBinaryStruct reads all of the symbol / value pairs and puts them
into a Struct.
// parseBinaryStruct reads all of the symbol / value pairs and puts them // into a Struct .
func parseBinaryStruct(ann []Symbol, lengthByte byte, r io.Reader) (Value, error) {
	if lengthByte == 0 {
		return Struct{annotations: ann, fields: []StructField{}}, nil
	}
	var numBytes uint32
	var errLength error
	if lengthByte == 1 {
		numBytes, errLength = readVarUInt32(r)
	} else {
		numBytes, errLength = determineLength32(lengthByte, r)
	}
	if errLength != nil {
		return nil, errors.WithMessage(errLength, "unable to parse length of struct")
	}
	data := make([]byte, numBytes)
	if n, err := r.Read(data); err != nil || n != int(numBytes) {
		return nil, errors.Errorf("unable to read struct - read %d bytes of %d with err: %v", n, numBytes, err)
	}
	fields := []StructField{}
	dataReader := bytes.NewReader(data)
	for dataReader.Len() > 0 {
		symbol, errSymbol := readVarUInt32(dataReader)
		if errSymbol != nil {
			return nil, errors.WithMessage(errSymbol, "unable to read struct field symbol")
		}
		value, errValue := parseNextBinaryValue(nil, dataReader)
		if errValue != nil {
			return nil, errors.WithMessage(errValue, "unable to read struct field value")
		}
		if value.Type() == TypePadding {
			continue
		}
		fields = append(fields, StructField{
			Symbol: Symbol{id: int32(symbol)},
			Value:  value,
		})
	}
	return Struct{annotations: ann, fields: fields}, nil
}
func parseBinaryStruct ( ann [ ] Symbol , lengthByte byte , r io . Reader ) ( Value , error ) { if lengthByte == 0 { return Struct { annotations : ann , fields : [ ] StructField { } } , nil } var numBytes uint32 var errLength error if lengthByte == 1 { numBytes , errLength = readVarUInt32 ( r ) } else { numBytes , errLength = determineLength32 ( lengthByte , r ) } if errLength != nil { return nil , errors . WithMessage ( errLength , " " ) } data := make ( [ ] byte , numBytes ) if n , err := r . Read ( data ) ; err != nil || n != int ( numBytes ) { return nil , errors . Errorf ( " " , n , numBytes , err ) } fields := [ ] StructField { } dataReader := bytes . NewReader ( data ) for dataReader . Len ( ) > 0 { symbol , errSymbol := readVarUInt32 ( dataReader ) if errSymbol != nil { return nil , errors . WithMessage ( errSymbol , " " ) } value , errValue := parseNextBinaryValue ( nil , dataReader ) if errValue != nil { return nil , errors . WithMessage ( errValue , " " ) } if value . Type ( ) == TypePadding { continue } fields = append ( fields , StructField { Symbol : Symbol { id : int32 ( symbol ) } , Value : value , } ) } return Struct { annotations : ann , fields : fields } , nil }
parseBinaryStruct reads all of the symbol / value pairs and puts them
into a Struct.
parseBinaryStruct reads all of the symbol / value pairs and puts them into a Struct .
// "When L is 1, the struct has at least one symbol/value pair, the length // field exists, and the field name integers are sorted in increasing order." // Not having any fields isn't the same as being null, so differentiate // between the two by ensuring that fields isn't nil even if it's empty. // Ignore padding.