github.com/batchcorp/thrift-iterator@v0.0.0-20220918180557-4c4a158fc6e9/raw/encode_list.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 rawListEncoder struct {
     9  }
    10  
    11  func (encoder *rawListEncoder) Encode(val interface{}, stream spi.Stream) {
    12  	obj := val.(List)
    13  	stream.WriteListHeader(obj.ElementType, len(obj.Elements))
    14  	for _, elem := range obj.Elements {
    15  		stream.Write(elem)
    16  	}
    17  }
    18  
    19  func (encoder *rawListEncoder) ThriftType() protocol.TType {
    20  	return protocol.TypeList
    21  }