{"modulePath":"github.com/hsqbyte/protospec","version":"v1.0.0","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package stack\n\nPackage stack provides multi-layer protocol stack decoding engine.\n\n## Functions\n\n```go\nfunc Encapsulate(lib *protocol.Library, layers []struct {\n\tProtocol string\n\tFields   map[string]any\n}) ([]byte, error)\n```\nEncapsulate wraps data in multiple protocol layers.\n\n## Types\n\n```go\ntype Engine struct {\n\t// contains filtered or unexported fields\n}\n```\nEngine is the multi-layer protocol stack decoder.\n\n```go\nfunc NewEngine(lib *protocol.Library) *Engine\n```\nNewEngine creates a new stack engine with default rules.\n\n```go\nfunc (e *Engine) AddRule(r Rule)\n```\nAddRule adds a dispatch rule.\n\n```go\nfunc (e *Engine) Decode(startProtocol string, data []byte) ([]Layer, error)\n```\nDecode decodes multiple protocol layers from raw data.\n\n```go\ntype Layer struct {\n\tProtocol string         `json:\"protocol\"`\n\tFields   map[string]any `json:\"fields\"`\n\tBytes    int            `json:\"bytes_read\"`\n}\n```\nLayer represents a decoded protocol layer.\n\n```go\ntype Rule struct {\n\tField string `json:\"field\"`\n\tValue any    `json:\"value\"`\n\tNext  string `json:\"next_protocol\"`\n}\n```\nRule defines a protocol dispatch rule.\n\n","path":"github.com/hsqbyte/protospec/src/stack","name":"stack","synopsis":"Package stack provides multi-layer protocol stack decoding engine.","isRedistributable":true}
