Documentation
¶
Index ¶
- func FormatCanonical(s *Schema, path, formatOverride string) ([]byte, error)
- func FormatDiff(d DiffResult) string
- func GenerateGo(s *Schema, pkg string) (string, error)
- func GenerateKaitai(s *Schema) (string, error)
- func GenerateWiresharkLua(s *Schema, protoName string) (string, error)
- func MarshalJSON(s *Schema) ([]byte, error)
- func MarshalYAML(s *Schema) ([]byte, error)
- func Validate(s *Schema) []error
- type AnnOverlay
- type DiffChange
- type DiffResult
- type Field
- type LintIssue
- type Schema
- func InferFromHypotheses(name string, constants []struct{ ... }, hyps []wt.Hypothesis) *Schema
- func LoadFile(path string, format string) (*Schema, error)
- func MergeAnnotations(s *Schema, anns []AnnOverlay) *Schema
- func UnmarshalAuto(b []byte, format string) (*Schema, error)
- func UnmarshalJSON(b []byte) (*Schema, error)
- func UnmarshalYAML(b []byte) (*Schema, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FormatCanonical ¶
FormatCanonical returns canonical YAML or JSON bytes for a schema (stable field order preserved). formatOverride is json|yaml|"" (inferred from path extension when empty).
func GenerateGo ¶
GenerateGo emits idiomatic ParseX code with bounds checks and typed errors.
func GenerateKaitai ¶
GenerateKaitai emits a Kaitai Struct (.ksy) YAML definition from a Wiretap schema.
func GenerateWiresharkLua ¶
GenerateWiresharkLua emits a stub Lua dissector for Wireshark.
func MarshalJSON ¶
MarshalJSON serializes a schema as indented JSON.
Types ¶
type AnnOverlay ¶
AnnOverlay is a minimal annotation overlay for MergeAnnotations (avoids project import).
type DiffChange ¶
type DiffChange struct {
Path string `json:"path"`
Kind string `json:"kind"` // added|removed|changed
Before string `json:"before,omitempty"`
After string `json:"after,omitempty"`
}
DiffChange describes one schema difference.
type DiffResult ¶
type DiffResult struct {
Changes []DiffChange `json:"changes"`
}
DiffResult holds schema comparison.
func Diff ¶
func Diff(a, b *Schema) DiffResult
Diff compares two schemas field-by-field (deterministic).
type Field ¶
type Field struct {
Name string `yaml:"name" json:"name"`
Offset *int `yaml:"offset,omitempty" json:"offset,omitempty"`
Length int `yaml:"length,omitempty" json:"length,omitempty"`
Type string `yaml:"type" json:"type"` // u8,u16,u32,u64,i8,...,bytes,string,bitfield,checksum,struct,array
Endian string `yaml:"endian,omitempty" json:"endian,omitempty"`
Encoding string `yaml:"encoding,omitempty" json:"encoding,omitempty"`
Value string `yaml:"value,omitempty" json:"value,omitempty"` // expected constant hex
Description string `yaml:"description,omitempty" json:"description,omitempty"`
Confidence string `yaml:"confidence,omitempty" json:"confidence,omitempty"`
Evidence string `yaml:"evidence,omitempty" json:"evidence,omitempty"`
Children []Field `yaml:"fields,omitempty" json:"fields,omitempty"`
Meta map[string]any `yaml:"meta,omitempty" json:"meta,omitempty"`
}
Field is one schema node (may contain children for nested structures).
type LintIssue ¶
LintIssue is a non-fatal schema quality finding.
type Schema ¶
type Schema struct {
Name string `yaml:"name" json:"name"`
Version string `yaml:"version,omitempty" json:"version,omitempty"`
Endian string `yaml:"endian,omitempty" json:"endian,omitempty"` // le|be|mixed
Fields []Field `yaml:"fields" json:"fields"`
Notes string `yaml:"notes,omitempty" json:"notes,omitempty"`
}
Schema is a nested protocol schema AST.
func InferFromHypotheses ¶
func InferFromHypotheses(name string, constants []struct { Start, End int Value byte }, hyps []wt.Hypothesis) *Schema
InferFromHypotheses builds a schema from high-confidence hypotheses + constants. Prefers typed fields over opaque ints, deconflicts overlaps, and may emit nested header structs / arrays.
func MergeAnnotations ¶
func MergeAnnotations(s *Schema, anns []AnnOverlay) *Schema
MergeAnnotations merges annotation overlays into a schema as trusted field overlays.
func UnmarshalAuto ¶
UnmarshalAuto parses JSON or YAML. format is json|yaml|"" (auto).
func UnmarshalJSON ¶
UnmarshalJSON parses a schema from JSON.
func UnmarshalYAML ¶
UnmarshalYAML parses a schema from YAML.