func (e *encoderDecoder) unmarshal(data []byte, tStruct thrift.TStruct) error { // TODO(pedge): size is not set within TMemoryBuffer, but from the implementation it does not // look like it matters, however this relies on an implementation detail tMemoryBuffer := &thrift.TMemoryBuffer{ Buffer: bytes.NewBuffer(data), } tProtocol := e.tProtocolFactory.GetProtocol(tMemoryBuffer) return tStruct.Read(tProtocol) }
func DeserializeThriftMessage(buf *bytes.Buffer, ts thrift.TStruct) (string, thrift.TMessageType, int32, error) { transport := thrift.NewStreamTransportR(buf) protocol := thrift.NewTBinaryProtocol(transport, false, false) name, typeId, seqId, err := protocol.ReadMessageBegin() if err != nil { return "", 0, 0, err } err = ts.Read(protocol) if err != nil { return "", 0, 0, err } return name, typeId, seqId, nil }