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.
 Click to show internal directories. 
   Click to hide internal directories.