func (b *Buffer) EncodeMessage(m Message) error {
	var err error
	b.buf = protowire.AppendVarint(b.buf, uint64(Size(m)))
	b.buf, err = marshalAppend(b.buf, m, b.deterministic)
	return err
}
EncodeMessage appends a length-prefixed encoded message to the buffer.
package proto
import (
	"errors"
	"fmt"
	"google.golang.org/protobuf/encoding/prototext"
	"google.golang.org/protobuf/encoding/protowire"
	"google.golang.org/protobuf/runtime/protoimpl"
)
const (
	WireVarint     = 0
	WireFixed32    = 5
	WireFixed64    = 1
	WireBytes      = 2
	WireStartGroup = 3
	WireEndGroup   = 4
)
func EncodeVarint(v uint64) []byte {
	return protowire.AppendVarint(nil, v)
}
func SizeVarint(v uint64) int {
	return protowire.SizeVarint(v)
}
func DecodeVarint(b []byte) (uint64, int) {
	v, n := protowire.ConsumeVarint(b)
	if n < 0 {
		return 0, 0
	}
	return v, n
}
type Buffer struct {
	buf           []byte
	idx           int
	deterministic bool
}
func NewBuffer(buf []byte) *Buffer {
	return &Buffer{buf: buf}
}
func (b *Buffer) SetDeterministic(deterministic bool) {
	b.deterministic = deterministic
}
func (b *Buffer) SetBuf(buf []byte) {
	b.buf = buf
	b.idx = 0
}
func (b *Buffer) Reset() {
	b.buf = b.buf[:0]
	b.idx = 0
}
func (b *Buffer) Bytes() []byte {
	return b.buf
}
func (b *Buffer) Unread() []byte {
	return b.buf[b.idx:]
}
func (b *Buffer) Marshal(m Message) error {
	var err error
	b.buf, err = marshalAppend(b.buf, m, b.deterministic)
	return err
}
func (b *Buffer) Unmarshal(m Message) error {
	err := UnmarshalMerge(b.Unread(), m)
	b.idx = len(b.buf)
	return err
}
type unknownFields struct{ XXX_unrecognized protoimpl.UnknownFields }
func (m *unknownFields) String() string { panic("not implemented") }
func (m *unknownFields) Reset()         { panic("not implemented") }
func (m *unknownFields) ProtoMessage()  { panic("not implemented") }
func (*Buffer) DebugPrint(s string, b []byte) {
	m := MessageReflect(new(unknownFields))
	m.SetUnknown(b)
	b, _ = prototext.MarshalOptions{AllowPartial: true, Indent: "\t"}.Marshal(m.Interface())
	fmt.Printf("==== %s ====\n%s==== %s ====\n", s, b, s)
}
func (b *Buffer) EncodeVarint(v uint64) error {
	b.buf = protowire.AppendVarint(b.buf, v)
	return nil
}
func (b *Buffer) EncodeZigzag32(v uint64) error {
	return b.EncodeVarint(uint64((uint32(v) << 1) ^ uint32((int32(v) >> 31))))
}
func (b *Buffer) EncodeZigzag64(v uint64) error {
	return b.EncodeVarint(uint64((uint64(v) << 1) ^ uint64((int64(v) >> 63))))
}
func (b *Buffer) EncodeFixed32(v uint64) error {
	b.buf = protowire.AppendFixed32(b.buf, uint32(v))
	return nil
}
func (b *Buffer) EncodeFixed64(v uint64) error {
	b.buf = protowire.AppendFixed64(b.buf, uint64(v))
	return nil
}
func (b *Buffer) EncodeRawBytes(v []byte) error {
	b.buf = protowire.AppendBytes(b.buf, v)
	return nil
}
func (b *Buffer) EncodeStringBytes(v string) error {
	b.buf = protowire.AppendString(b.buf, v)
	return nil
}