github.com/batchcorp/thrift-iterator@v0.0.0-20220918180557-4c4a158fc6e9/raw/decode_struct.go (about)

     1  package raw
     2  
     3  import (
     4  	"github.com/batchcorp/thrift-iterator/spi"
     5  	"github.com/batchcorp/thrift-iterator/protocol"
     6  )
     7  
     8  type rawStructDecoder struct {
     9  }
    10  
    11  func (decoder *rawStructDecoder) Decode(val interface{}, iter spi.Iterator) {
    12  	fields := Struct{}
    13  	iter.ReadStructHeader()
    14  	for {
    15  		fieldType, fieldId := iter.ReadStructField()
    16  		if fieldType == protocol.TypeStop {
    17  			*val.(*Struct) = fields
    18  			return
    19  		}
    20  		fields[fieldId] = StructField{
    21  			Type:   fieldType,
    22  			Buffer: iter.Skip(fieldType, nil),
    23  		}
    24  	}
    25  }