Documentation
¶
Overview ¶
Package binary provides helpers for encoding binary data from a spec file very loosely based on kaitai; see https://doc.kaitai.io.
Index ¶
- func ReadF32(rdr io.Reader, endian binary.ByteOrder) float32
- func ReadF64(rdr io.Reader, endian binary.ByteOrder) float64
- func ReadS8(rdr io.Reader, endian binary.ByteOrder) int8
- func ReadS16(rdr io.Reader, endian binary.ByteOrder) int16
- func ReadS32(rdr io.Reader, endian binary.ByteOrder) int32
- func ReadS64(rdr io.Reader, endian binary.ByteOrder) int64
- func ReadU8(rdr io.Reader, endian binary.ByteOrder) uint8
- func ReadU16(rdr io.Reader, endian binary.ByteOrder) uint16
- func ReadU32(rdr io.Reader, endian binary.ByteOrder) uint32
- func ReadU64(rdr io.Reader, endian binary.ByteOrder) uint64
- type EvalFunc
- type Instance
- type Meta
- type Sequence
- type Spec
- type Type
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Instance ¶ added in v1.3.4
type Instance struct {
Sequence `yaml:",inline"`
// Pos is the position of the data in the byte stream
Pos *string `yaml:"pos,omitempty"`
// Value is the computed value of the instance object
Value *string `yaml:"value,omitempty"`
// contains filtered or unexported fields
}
Instance is an instance definition
type Meta ¶
type Meta struct {
ID string `yaml:"id"`
Endian string `yaml:"endian"`
Encoding string `yaml:"encoding"`
}
Meta provides meta-information for the spec
type Sequence ¶
type Sequence struct {
// ID is the label for the field
ID string `yaml:"id"`
// Type defines the type, width, and byte order or a custom definde type
Type string `yaml:"type"`
// Size is the length of the field in bytes, or points to another sequence value
Size *string `yaml:"size,omitempty"`
// Repeat is used for array values
Repeat *string `yaml:"repeat,omitempty"`
// RepeatExpression is evaluated to determine the number of times to repeat
RepeatExpression *string `yaml:"repeat-expr,omitempty"`
// Omit when set will omit the sequence value from the final result
Omit bool `yaml:"omit"`
// contains filtered or unexported fields
}
Sequence is a field definition
type Spec ¶
type Spec struct {
Meta Meta `yaml:"meta"`
Sequence []*Sequence `yaml:"seq"`
Instances map[string]*Instance `yaml:"instances"`
Types map[string]*Type `yaml:"types,omitempty"`
// contains filtered or unexported fields
}
Spec defines the specification
func (*Spec) AddEvalFunc ¶ added in v1.3.7
AddEvalFunc add an evaluator function
Click to show internal directories.
Click to hide internal directories.