packet

package
v0.0.0-...-c7544f2 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MarshalCommand

func MarshalCommand(cmd Command) ([]byte, error)

MarshalCommand will serialize a command including the length field

Types

type Command

type Command interface {
	Slug() string
	encoding.BinaryMarshaler
	encoding.BinaryUnmarshaler
}

func UnmarshalCommand

func UnmarshalCommand(data []byte) (Command, error)

UnmarshalCommand will deserialize a command from bytes (excluding length field)

type Flags

type Flags uint8
const (
	FlagNeedACK Flags = 1 << iota
	FlagInit
	FlagRetrans
	FlagHello
	FlagACK
)

func FlagsFrom

func FlagsFrom(masks ...Flags) Flags

func (Flags) Debug

func (f Flags) Debug() logrus.Fields

func (Flags) Has

func (f Flags) Has(mask Flags) bool

type Message

type Message struct {
	Flags     Flags  // max: 5 bit
	Length    uint16 // max: 11 bit
	SessionID uint16
	AckID     uint16
	SeqNum    uint16

	Commands []Command
}

func Deserialize

func Deserialize(log logrus.FieldLogger, buf *bytes.Buffer) (Message, error)

func (*Message) Serialize

func (m *Message) Serialize(buf *bytes.Buffer)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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