mq_coder/packet.go

39 lines
725 B
Go

package mq_coder
import (
"bytes"
)
// packet is the base type of the NodePacket and PrimitivePacket
type packet struct {
tag *Tag
length int
valBuf []byte
buf *bytes.Buffer
}
// GetRawBytes get all raw bytes of this packet
func (bp *packet) GetRawBytes() []byte {
return bp.buf.Bytes()
}
// Length return the length of Val this packet
func (bp *packet) Length() int {
return bp.length
}
// SeqId returns Tag of this packet
func (bp *packet) SeqId() byte {
return bp.tag.SeqId()
}
// IsSlice determine if the current node is a Slice
func (bp *packet) IsSlice() bool {
return bp.tag.IsSlice()
}
// GetValBuf get raw buffer of Val of this packet
func (bp *packet) GetValBuf() []byte {
return bp.valBuf
}