message

package
v1.0.0-rc.3 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2023 License: Apache-2.0, BSD-2-Clause Imports: 1 Imported by: 1

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 requested.
	ErrUnknownType = errors.New("message type unknown")
)

Functions

This section is empty.

Types

type Definition

type Definition struct {
	// ID defines the unique identifier of the message.
	ID Type
	// MaxBytesLength defines the max byte length of the message type.
	// when 0, it means a message can be arbitrary size
	MaxBytesLength uint16
	// VariableLength defines if the message length is variable.
	VariableLength bool
}

Definition describes a message's ID, its max byte length and whether its size can be variable.

type Registry

type Registry struct {
	// contains filtered or unexported fields
}

Registry holds message definitions.

func NewRegistry

func NewRegistry(defs []*Definition) *Registry

NewRegistry creates and initializes a new Registry. Once it is done, the Registry is immutable. Message definitions should be strictly monotonically increasing (based on their Message Type (uint16)).

func (*Registry) DefinitionForType

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

DefinitionForType returns the definition for the given message type.

func (*Registry) Definitions

func (r *Registry) 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