func NewDataIfNeeded(method string, message remote.Message) error {
	if message.Data() != nil {
		return nil
	}
	if message.NewData(method) {
		return nil
	}
	return remote.NewTransErrorWithMsg(remote.InternalError, "message data for codec is nil")
}
NewDataIfNeeded is used to create the data if not exist.
package codec
import (
	"errors"
	"fmt"
	"github.com/cloudwego/kitex/pkg/remote"
	"github.com/cloudwego/kitex/pkg/rpcinfo"
)
const (
	FrontMask = 0x0000ffff
)
func SetOrCheckMethodName(methodName string, message remote.Message) error {
	ri := message.RPCInfo()
	ink := ri.Invocation()
	callMethodName := ink.MethodName()
	if methodName == "" {
		return fmt.Errorf("method name that receive is empty")
	}
	if callMethodName == methodName {
		return nil
	}
	if message.RPCRole() == remote.Client {
		return fmt.Errorf("wrong method name, expect=%s, actual=%s", callMethodName, methodName)
	}
	if ink, ok := ink.(rpcinfo.InvocationSetter); ok {
		ink.SetMethodName(methodName)
	} else {
		return errors.New("the interface Invocation doesn't implement InvocationSetter")
	}
	svcInfo := message.ServiceInfo()
	if mt := svcInfo.MethodInfo(methodName); mt == nil {
		return remote.NewTransErrorWithMsg(remote.UnknownMethod, fmt.Sprintf("unknown method %s", methodName))
	}
	rpcinfo.AsMutableEndpointInfo(ri.To()).SetMethod(methodName)
	return nil
}
func SetOrCheckSeqID(seqID int32, message remote.Message) error {
	switch message.MessageType() {
	case remote.Call:
		if ink, ok := message.RPCInfo().Invocation().(rpcinfo.InvocationSetter); ok {
			ink.SetSeqID(seqID)
		} else {
			return errors.New("the interface Invocation doesn't implement InvocationSetter")
		}
	case remote.Reply:
		expectSeqID := message.RPCInfo().Invocation().SeqID()
		if expectSeqID != seqID {
			methodName := message.RPCInfo().Invocation().MethodName()
			return remote.NewTransErrorWithMsg(remote.BadSequenceID, fmt.Sprintf("method[%s] out of order sequence response, expect[%d], receive[%d]", methodName, expectSeqID, seqID))
		}
	case remote.Exception:
	}
	return nil
}
func UpdateMsgType(msgType uint32, message remote.Message) error {
	rpcRole := message.RPCRole()
	mt := remote.MessageType(msgType)
	if mt == message.MessageType() {
		return nil
	}
	if rpcRole == remote.Server {
		if mt != remote.Call && mt != remote.Oneway && mt != remote.Stream {
			return remote.NewTransErrorWithMsg(remote.InvalidMessageTypeException, fmt.Sprintf("server side, invalid message type %d", mt))
		}
	} else {
		if mt != remote.Reply && mt != remote.Exception && mt != remote.Stream {
			return remote.NewTransErrorWithMsg(remote.InvalidMessageTypeException, fmt.Sprintf("client side, invalid message type %d", mt))
		}
	}
	message.SetMessageType(mt)
	return nil
}