message

package
v0.5.0-rc8 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2020 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrTypeAlreadyDefined is returned when an already defined message type is redefined.
	ErrTypeAlreadyDefined = errors.New("message type is already defined")
	// ErrUnknownType is returned when a definition for an unknown message type is is requested.
	ErrUnknownType = errors.New("message type unknown")
)

Functions

func RegisterType

func RegisterType(msgType Type, def *Definition) error

RegisterType registers the given message type with its definition.

Types

type Definition

type Definition struct {
	ID             Type
	MaxBytesLength uint16
	// VariableLength defines if the message is fixed size or not
	// if it is fixed, the message length must be MaxBytesLength
	VariableLength bool
}

Definition describes a message's ID and its max byte length (and whether the length variable).

func DefinitionForType

func DefinitionForType(msgType Type) (*Definition, error)

DefinitionForType returns the definition for the given message type.

func Definitions

func Definitions() []*Definition

Definitions returns all registered message definitions.

type Type

type Type byte

Type denotes the byte ID of a given message type.

Jump to

Keyboard shortcuts

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