message

package
v0.1.11 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2023 License: Apache-2.0, BSD-2-Clause Imports: 1 Imported by: 2 modules, 1 package

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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