metadata

package
v0.8.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 23, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PacketPing  = uint16(10) // PING
	PacketPong  = uint16(11) // PONG
	PacketProbe = uint16(12) // PACKET
)
View Source
const (
	IdOffset = 0 // 0
	IdSize   = 2

	OperationOffset = IdOffset + IdSize // 2
	OperationSize   = 2

	ContentLengthOffset = OperationOffset + OperationSize // 4
	ContentLengthSize   = 4

	Size = ContentLengthOffset + ContentLengthSize // 8
)

Variables

View Source
var (
	EncodingErr            = errors.New("error while encoding metadata")
	DecodingErr            = errors.New("error while decoding metadata")
	InvalidBufferLengthErr = errors.New("invalid buffer length")
)

Functions

func PutBuffer

func PutBuffer(b *Buffer)

Types

type Buffer

type Buffer [Size]byte

func Encode

func Encode(id, operation uint16, contentLength uint32) (*Buffer, error)

func GetBuffer

func GetBuffer() *Buffer

func NewBuffer

func NewBuffer() *Buffer

func (*Buffer) Reset

func (b *Buffer) Reset()

type Metadata

type Metadata struct {
	Id            uint16 // 2 Bytes
	Operation     uint16 // 2 Bytes
	ContentLength uint32 // 4 Bytes
}

Metadata is 8 bytes in length

func Decode

func Decode(buf []byte) (*Metadata, error)

func (*Metadata) Decode

func (fm *Metadata) Decode(buf *Buffer) (err error)

Decode Metadata

func (*Metadata) Encode

func (fm *Metadata) Encode() (b *Buffer, err error)

Encode Metadata

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL