func (p *PayloadFrame) MetadataUTF8() (metadata string, ok bool) {
	raw, ok := p.Metadata()
	if ok {
		metadata = bytesconv.BytesToString(raw)
	}
	return
}
MetadataUTF8 returns metadata as UTF8 string.
package framing
import (
	"github.com/rsocket/rsocket-go/core"
	"github.com/rsocket/rsocket-go/internal/bytesconv"
	"github.com/rsocket/rsocket-go/internal/common"
	"github.com/rsocket/rsocket-go/internal/u24"
)
type PayloadFrame struct {
	*bufferedFrame
}
func NewPayloadFrame(id uint32, data, metadata []byte, flag core.FrameFlag) *PayloadFrame {
	if len(metadata) > 0 {
		flag |= core.FlagMetadata
	}
	bb := common.BorrowByteBuff()
	if err := core.WriteFrameHeader(bb, id, core.FrameTypePayload, flag); err != nil {
		common.ReturnByteBuff(bb)
		panic(err)
	}
	if len(metadata) > 0 {
		if err := u24.WriteUint24(bb, len(metadata)); err != nil {
			common.ReturnByteBuff(bb)
			panic(err)
		}
		if _, err := bb.Write(metadata); err != nil {
			common.ReturnByteBuff(bb)
			panic(err)
		}
	}
	if len(data) > 0 {
		if _, err := bb.Write(data); err != nil {
			common.ReturnByteBuff(bb)
			panic(err)
		}
	}
	return &PayloadFrame{
		bufferedFrame: newBufferedFrame(bb),
	}
}
func (p *PayloadFrame) Validate() (err error) {
	if p.HasFlag(core.FlagMetadata) && p.bodyLen() < 3 {
		err = errIncompleteFrame
	}
	return
}
func (p *PayloadFrame) Metadata() ([]byte, bool) {
	return p.trySliceMetadata(0)
}
func (p *PayloadFrame) Data() []byte {
	return p.trySliceData(0)
}