Documentation
¶
Index ¶
- type Codec
- type DecodeResult
- type Library
- func (l *Library) AllNames() []string
- func (l *Library) CreateCodec(pslText string) (*Codec, error)
- func (l *Library) Decode(protocolName string, data []byte) (*DecodeResult, error)
- func (l *Library) Encode(protocolName string, packet map[string]any) ([]byte, error)
- func (l *Library) LoadPSL(filePath string) error
- func (l *Library) Message(name string) *schema.MessageSchema
- func (l *Library) Meta(name string) *ProtocolMeta
- func (l *Library) RegisterChecksum(name string, fn checksum.ChecksumFunc)
- func (l *Library) RegisterFormat(name string, formatter format.DisplayFormatter)
- func (l *Library) Registry() *registry.ProtocolRegistry
- type ProtocolMeta
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.
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 ¶
NewLibrary creates a Library with default registries and loads all built-in PSL files from the psl/ directory.
func (*Library) AllNames ¶
AllNames returns all registered protocol names (binary + message) in sorted order.
func (*Library) CreateCodec ¶
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) 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.