protocol

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2026 License: GPL-3.0 Imports: 12 Imported by: ? modules, 0 packages

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

This section is empty.

Functions

This section is empty.

Types

type Codec

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

Codec is a standalone encoder/decoder created from PSL text without registering the protocol.

func (*Codec) Decode

func (c *Codec) Decode(data []byte) (*DecodeResult, error)

Decode decodes raw bytes using this codec's schema.

func (*Codec) Encode

func (c *Codec) Encode(packet map[string]any) ([]byte, error)

Encode encodes a packet using this codec's schema.

type DecodeResult

type DecodeResult = codec.DecodeResult

DecodeResult re-exports the codec DecodeResult for public use.

type Library

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

Library is the top-level API for protocol encoding and decoding.

func NewLibrary

func NewLibrary() (*Library, error)

NewLibrary creates a Library with default registries and loads all built-in PSL files from the psl/ directory.

func (*Library) AllNames

func (l *Library) AllNames() []string

AllNames returns all registered protocol names (binary + message) in sorted order.

func (*Library) CreateCodec

func (l *Library) CreateCodec(pslText string) (*Codec, error)

CreateCodec creates a standalone Codec from PSL text without registering.

func (*Library) Decode

func (l *Library) Decode(protocolName string, data []byte) (*DecodeResult, error)

Decode decodes raw bytes by protocol name.

func (*Library) Encode

func (l *Library) Encode(protocolName string, packet map[string]any) ([]byte, error)

Encode encodes a packet by protocol name.

func (*Library) LoadPSL

func (l *Library) LoadPSL(filePath string) error

LoadPSL loads a PSL file and registers the protocol.

func (*Library) Message

func (l *Library) Message(name string) *schema.MessageSchema

Message returns the MessageSchema for the given protocol name, or nil if not found.

func (*Library) Meta

func (l *Library) Meta(name string) *ProtocolMeta

Meta returns the ProtocolMeta for the given protocol name, or nil if not found.

func (*Library) RegisterChecksum

func (l *Library) RegisterChecksum(name string, fn checksum.ChecksumFunc)

RegisterChecksum registers a custom checksum algorithm.

func (*Library) RegisterFormat

func (l *Library) RegisterFormat(name string, formatter format.DisplayFormatter)

RegisterFormat registers a custom display format converter.

func (*Library) Registry

func (l *Library) Registry() *registry.ProtocolRegistry

Registry returns the underlying protocol registry.

type ProtocolMeta

type ProtocolMeta struct {
	RFC         string                       `json:"rfc"`
	URL         string                       `json:"url"`
	Title       map[string]string            `json:"title"`
	Description map[string]string            `json:"description"`
	Status      string                       `json:"status"`
	SeeAlso     []string                     `json:"see_also"`
	Type        string                       `json:"type"`
	Layer       string                       `json:"layer"`
	DependsOn   []string                     `json:"depends_on"`
	Fields      map[string]map[string]string `json:"fields"`
}

ProtocolMeta holds metadata loaded from meta.json alongside a protocol.

Jump to

Keyboard shortcuts

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