Versions in this module Expand all Collapse all v1 v1.1.0 Nov 12, 2025 v1.0.0 Oct 3, 2025 Changes in this version + const CodeBinarySizeMismatch + const CodeBinarySizeRequired + const CodeInsufficientBits + const CodeInvalidBinaryData + const CodeInvalidBitstringData + const CodeInvalidEndianness + const CodeInvalidFloatSize + const CodeInvalidSegment + const CodeInvalidSize + const CodeInvalidType + const CodeInvalidUnicodeCodepoint + const CodeInvalidUnit + const CodeOverflow + const CodeSignedOverflow + const CodeTypeMismatch + const CodeUTFSizeSpecified + const CodeUTFUnitModified + const DefaultSizeFloat + const DefaultSizeInteger + const DefaultUnitBinary + const DefaultUnitBitstring + const DefaultUnitFloat + const DefaultUnitInteger + const DefaultUnitUTF + const EndiannessBig + const EndiannessLittle + const EndiannessNative + const Signed + const TypeBinary + const TypeBitstring + const TypeFloat + const TypeInteger + const TypeRestBinary + const TypeRestBitstring + const TypeUTF + const TypeUTF16 + const TypeUTF32 + const TypeUTF8 + const Unsigned + var ErrInvalidAlignment = errors.New("invalid alignment") + var ErrInvalidPosition = errors.New("invalid position") + var ErrInvalidSize = errors.New("invalid size") + var ErrLengthTooLarge = errors.New("length too large") + var ErrSizeTooLarge = errors.New("size too large") + func AlignData(data []byte, offset, alignment uint) ([]byte, error) + func CalculateTotalSize(segment Segment) (uint, error) + func CountLeadingZeros(data []byte) uint + func CountTrailingZeros(data []byte) uint + func ExtractBits(data []byte, start, length uint) ([]byte, error) + func GetBitValue(data []byte, pos uint) (bool, error) + func PadData(data []byte, bitLen, target uint) []byte + func SetBitValue(data []byte, pos uint, value bool) error + func SetBits(target, data []byte, start uint) error + func ValidateSegment(segment *Segment) error + func ValidateSize(size uint, unit uint) error + type BitString struct + func NewBitString() *BitString + func NewBitStringFromBits(data []byte, length uint) *BitString + func NewBitStringFromBytes(data []byte) *BitString + func (bs *BitString) Clone() *BitString + func (bs *BitString) IsBinary() bool + func (bs *BitString) IsEmpty() bool + func (bs *BitString) Length() uint + func (bs *BitString) ToBytes() []byte + type BitStringError struct + Code string + Context interface{} + Message string + func NewBitStringError(code, message string) *BitStringError + func NewBitStringErrorWithContext(code, message string, context interface{}) *BitStringError + func (e *BitStringError) Error() string + type Segment struct + DynamicExpr string + DynamicSize *uint + Endianness string + IsDynamic bool + Signed bool + Size uint + SizeSpecified bool + Type string + Unit uint + UnitSpecified bool + Value interface{} + func NewSegment(value interface{}, options ...SegmentOption) *Segment + type SegmentOption func(*Segment) + func WithDynamicSize(sizeVar *uint) SegmentOption + func WithDynamicSizeExpression(expr string) SegmentOption + func WithEndianness(endianness string) SegmentOption + func WithSigned(signed bool) SegmentOption + func WithSize(size uint) SegmentOption + func WithType(segmentType string) SegmentOption + func WithUnit(unit uint) SegmentOption + type SegmentResult struct + Matched bool + Remaining *BitString + Value interface{}