binx

package
v1.3.6-beta3 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2024 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Exports = map[string]any{
	"Read": BinaryRead,

	"toInt":    NewInt64,
	"toInt8":   NewInt8,
	"toInt16":  NewInt16,
	"toInt32":  NewInt32,
	"toInt64":  NewInt64,
	"toUint":   NewUint64,
	"toUint8":  NewUint8,
	"toUint16": NewUint16,
	"toUint32": NewUint32,
	"toUint64": NewUint64,
	"toBytes":  NewBytes,
	"toRaw":    NewBytes,
	"toBool":   NewBool,

	"toList":   NewListDescriptor,
	"toStruct": NewStructDescriptor,
}

Functions

This section is empty.

Types

type BinaryTypeVerbose

type BinaryTypeVerbose string
var Bool BinaryTypeVerbose = "bool"
var Bytes BinaryTypeVerbose = "bytes"
var Int16 BinaryTypeVerbose = "int16"
var Int32 BinaryTypeVerbose = "int32"
var Int64 BinaryTypeVerbose = "int64"
var Int8 BinaryTypeVerbose = "int8"
var Uint16 BinaryTypeVerbose = "uint16"
var Uint32 BinaryTypeVerbose = "uint32"
var Uint64 BinaryTypeVerbose = "uint64"
var Uint8 BinaryTypeVerbose = "uint8"

type ByteOrderEnum

type ByteOrderEnum int
var (
	BigEndianByteOrder    ByteOrderEnum = 0
	NetworkByteOrder                    = BigEndianByteOrder
	LittleEndianByteOrder ByteOrderEnum = 1
)

type ListResult

type ListResult struct {
	*ResultBase

	Length int
	Result []ResultIf
}

func NewListResult

func NewListResult() *ListResult

func (*ListResult) SetResults

func (r *ListResult) SetResults(i []ResultIf)

type PartDescriptor

type PartDescriptor struct {
	Identifier        string
	IdentifierVerbose string

	// List / Struct
	// if SubPartLength > 0 ? use List
	// if SubPartLength <= 0 ? use struct
	SubPartLength     uint64
	SubPartDescriptor []*PartDescriptor

	ByteOrder ByteOrderEnum
	// contains filtered or unexported fields
}

func NewBool

func NewBool(name string, verbose ...string) *PartDescriptor

func NewBuffer

func NewBuffer(name string, size any) *PartDescriptor

func NewByte

func NewByte(name string, values ...string) *PartDescriptor

func NewBytes

func NewBytes(name string, size any) *PartDescriptor

func NewDefaultNetworkPartDescriptor

func NewDefaultNetworkPartDescriptor() *PartDescriptor

func NewInt16

func NewInt16(name string, values ...string) *PartDescriptor

func NewInt32

func NewInt32(name string, values ...string) *PartDescriptor

func NewInt64

func NewInt64(name string, values ...string) *PartDescriptor

func NewInt8

func NewInt8(name string, values ...string) *PartDescriptor

func NewListDescriptor

func NewListDescriptor(builder ...*PartDescriptor) *PartDescriptor

func NewPartDescriptor added in v1.3.0

func NewPartDescriptor(dataType BinaryTypeVerbose, size uint64) *PartDescriptor

func NewStructDescriptor

func NewStructDescriptor(builder ...*PartDescriptor) *PartDescriptor

func NewUint16

func NewUint16(name string, values ...string) *PartDescriptor

func NewUint32

func NewUint32(name string, values ...string) *PartDescriptor

func NewUint64

func NewUint64(name string, values ...string) *PartDescriptor

func NewUint8

func NewUint8(name string, values ...string) *PartDescriptor

builder

func (*PartDescriptor) Config

func (p *PartDescriptor) Config(i ...PartDescriptorBuilder)

func (*PartDescriptor) GetTimeoutDuration

func (p *PartDescriptor) GetTimeoutDuration() time.Duration

func (*PartDescriptor) IsEmpty

func (p *PartDescriptor) IsEmpty() bool

func (*PartDescriptor) Name

func (p *PartDescriptor) Name(id string, verbose ...string) *PartDescriptor

func (*PartDescriptor) SetIdentifier

func (p *PartDescriptor) SetIdentifier(id string, verbose ...string) *PartDescriptor

func (*PartDescriptor) Verbose

func (p *PartDescriptor) Verbose(verbose ...string) *PartDescriptor

type PartDescriptorBuilder

type PartDescriptorBuilder func(*PartDescriptor)

type Result

type Result struct {
	*ResultBase

	Type        BinaryTypeVerbose
	TypeVerbose string
}

func NewResult

func NewResult(raw []byte) *Result

func (*Result) Value

func (r *Result) Value() any

type ResultBase

type ResultBase struct {
	Bytes             []byte
	Identifier        string
	IdentifierVerbose string
	Offset            int64
	ByteOrder         ByteOrderEnum
}

func (*ResultBase) AsBool

func (r *ResultBase) AsBool() bool

func (*ResultBase) AsInt

func (r *ResultBase) AsInt() int

func (*ResultBase) AsInt16

func (r *ResultBase) AsInt16() int16

func (*ResultBase) AsInt32

func (r *ResultBase) AsInt32() int32

func (*ResultBase) AsInt64

func (r *ResultBase) AsInt64() int64

func (*ResultBase) AsInt8

func (r *ResultBase) AsInt8() int8

func (*ResultBase) AsString

func (r *ResultBase) AsString() string

func (*ResultBase) AsUint

func (r *ResultBase) AsUint() uint

func (*ResultBase) AsUint16

func (r *ResultBase) AsUint16() uint16

func (*ResultBase) AsUint32

func (r *ResultBase) AsUint32() uint32

func (*ResultBase) AsUint64

func (r *ResultBase) AsUint64() uint64

func (*ResultBase) AsUint8

func (r *ResultBase) AsUint8() uint8

func (*ResultBase) BigEndian

func (s *ResultBase) BigEndian() ResultIf

func (*ResultBase) GetBytes

func (r *ResultBase) GetBytes() []byte

func (*ResultBase) GetInt64Offset

func (r *ResultBase) GetInt64Offset() int64

func (*ResultBase) GetOffset

func (r *ResultBase) GetOffset() int

func (*ResultBase) LittleEndian

func (s *ResultBase) LittleEndian() ResultIf

func (*ResultBase) NetworkByteOrder

func (s *ResultBase) NetworkByteOrder() ResultIf

func (*ResultBase) SetBytes

func (r *ResultBase) SetBytes(b []byte)

func (*ResultBase) SetOffset

func (r *ResultBase) SetOffset(i int64)

func (*ResultBase) Value

func (r *ResultBase) Value() any

type ResultCompactIf

type ResultCompactIf interface {
	ResultIf

	SetBytes([]byte)
	SetOffset(int64)
	SetResults([]ResultIf)
}

type ResultIf

type ResultIf interface {
	GetBytes() []byte
	GetInt64Offset() int64
	GetOffset() int

	NetworkByteOrder() ResultIf
	BigEndian() ResultIf
	LittleEndian() ResultIf

	AsInt() int
	AsInt8() int8
	AsInt16() int16
	AsInt32() int32
	AsInt64() int64
	AsUint() uint
	AsUint8() uint8
	AsUint16() uint16
	AsUint32() uint32
	AsUint64() uint64
	AsBool() bool
	AsString() string
	Value() any
}

func BinaryRead

func BinaryRead(data any, descriptors ...*PartDescriptor) ([]ResultIf, error)

func FindResultByIdentifier

func FindResultByIdentifier(results []ResultIf, name string) ResultIf

type StructResult

type StructResult struct {
	*ResultBase

	Result []ResultIf
}

func NewStructResult

func NewStructResult() *StructResult

func (*StructResult) SetResults

func (r *StructResult) SetResults(i []ResultIf)

Jump to

Keyboard shortcuts

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