funbit

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TypeBitstring = bitstringpkg.TypeBitstring
	TypeBinary    = bitstringpkg.TypeBinary
	TypeInteger   = bitstringpkg.TypeInteger
	TypeFloat     = bitstringpkg.TypeFloat
	TypeUTF       = bitstringpkg.TypeUTF
	TypeUTF8      = bitstringpkg.TypeUTF8
	TypeUTF16     = bitstringpkg.TypeUTF16
	TypeUTF32     = bitstringpkg.TypeUTF32
)

Type constants

View Source
const (
	EndiannessBig    = bitstringpkg.EndiannessBig
	EndiannessLittle = bitstringpkg.EndiannessLittle
	EndiannessNative = bitstringpkg.EndiannessNative
)

Endianness constants

View Source
const (
	ErrOverflow                = bitstringpkg.CodeOverflow
	ErrSignedOverflow          = bitstringpkg.CodeSignedOverflow
	ErrInsufficientBits        = bitstringpkg.CodeInsufficientBits
	ErrInvalidSize             = bitstringpkg.CodeInvalidSize
	ErrInvalidType             = bitstringpkg.CodeInvalidType
	ErrInvalidEndianness       = bitstringpkg.CodeInvalidEndianness
	ErrBinarySizeRequired      = bitstringpkg.CodeBinarySizeRequired
	ErrBinarySizeMismatch      = bitstringpkg.CodeBinarySizeMismatch
	ErrInvalidBinaryData       = bitstringpkg.CodeInvalidBinaryData
	ErrInvalidBitstringData    = bitstringpkg.CodeInvalidBitstringData
	ErrUTFSizeSpecified        = bitstringpkg.CodeUTFSizeSpecified
	ErrInvalidUnicodeCodepoint = bitstringpkg.CodeInvalidUnicodeCodepoint
	ErrTypeMismatch            = bitstringpkg.CodeTypeMismatch
	ErrInvalidSegment          = bitstringpkg.CodeInvalidSegment
	ErrInvalidUnit             = bitstringpkg.CodeInvalidUnit
	ErrInvalidFloatSize        = bitstringpkg.CodeInvalidFloatSize
	ErrUTFUnitModified         = bitstringpkg.CodeUTFUnitModified
)

Error code constants

View Source
const (
	DefaultSizeInteger = bitstringpkg.DefaultSizeInteger
	DefaultSizeFloat   = bitstringpkg.DefaultSizeFloat
)

Default size constants

Variables

This section is empty.

Functions

func AddBinary

func AddBinary(b *Builder, value []byte, options ...SegmentOption)

AddBinary adds binary data to the builder

func AddBitstring

func AddBitstring(b *Builder, value *BitString, options ...SegmentOption)

AddBitstring adds a bitstring to the builder

func AddFloat

func AddFloat(b *Builder, value interface{}, options ...SegmentOption)

AddFloat adds a float to the builder

func AddInteger

func AddInteger(b *Builder, value interface{}, options ...SegmentOption)

AddInteger adds an integer to the builder

func AddUTF

func AddUTF(b *Builder, value string, options ...SegmentOption)

AddUTF adds UTF-encoded string data to the builder

func AddUTF8

func AddUTF8(b *Builder, value string, options ...SegmentOption)

AddUTF8 adds UTF-8 encoded string data to the builder

func AddUTF8Codepoint

func AddUTF8Codepoint(b *Builder, codepoint int, options ...SegmentOption)

AddUTF8Codepoint adds a single UTF-8 encoded codepoint to the builder This is equivalent to Erlang's <<Codepoint/utf8>>

func AddUTF16

func AddUTF16(b *Builder, value string, options ...SegmentOption)

AddUTF16 adds UTF-16 encoded string data to the builder

func AddUTF16Codepoint

func AddUTF16Codepoint(b *Builder, codepoint int, options ...SegmentOption)

AddUTF16Codepoint adds a single UTF-16 encoded codepoint to the builder This is equivalent to Erlang's <<Codepoint/utf16>>

func AddUTF32

func AddUTF32(b *Builder, value string, options ...SegmentOption)

AddUTF32 adds UTF-32 encoded string data to the builder

func AddUTF32Codepoint

func AddUTF32Codepoint(b *Builder, codepoint int, options ...SegmentOption)

AddUTF32Codepoint adds a single UTF-32 encoded codepoint to the builder This is equivalent to Erlang's <<Codepoint/utf32>>

func Binary

func Binary(m *Matcher, variable interface{}, options ...SegmentOption)

Binary adds a binary segment to the matcher

func BitsToInt

func BitsToInt(bits []byte, signed bool) (int64, error)

BitsToInt converts bits to an integer

func Bitstring

func Bitstring(m *Matcher, variable interface{}, options ...SegmentOption)

Bitstring adds a bitstring segment to the matcher

func ConvertEndianness

func ConvertEndianness(data []byte, from, to string, size uint) ([]byte, error)

ConvertEndianness converts data between different endianness

func CountBits

func CountBits(data []byte) uint

CountBits counts the number of set bits in data

func DecodeUTF8

func DecodeUTF8(data []byte) (string, error)

DecodeUTF8 decodes UTF-8 bytes to a string

func DecodeUTF16

func DecodeUTF16(data []byte, endianness string) (string, error)

DecodeUTF16 decodes UTF-16 bytes to a string

func EncodeUTF8

func EncodeUTF8(text string) ([]byte, error)

EncodeUTF8 encodes a string to UTF-8 bytes

func EncodeUTF16

func EncodeUTF16(text string, endianness string) ([]byte, error)

EncodeUTF16 encodes a string to UTF-16 bytes

func ExtractBits

func ExtractBits(data []byte, startBit, numBits uint) ([]byte, error)

ExtractBits extracts a range of bits from data

func Float

func Float(m *Matcher, variable interface{}, options ...SegmentOption)

Float adds a float segment to the matcher

func GetBitValue

func GetBitValue(data []byte, bitIndex uint) (bool, error)

GetBitValue gets the value of a specific bit

func GetNativeEndianness

func GetNativeEndianness() string

GetNativeEndianness returns the native endianness

func IntToBits

func IntToBits(value int64, size uint, signed bool) ([]byte, error)

IntToBits converts an integer to bits

func Integer

func Integer(m *Matcher, variable interface{}, options ...SegmentOption)

Integer adds an integer segment to the matcher

func IsValidUnicodeCodePoint

func IsValidUnicodeCodePoint(codePoint int) bool

IsValidUnicodeCodePoint checks if a code point is valid Unicode

func RegisterVariable

func RegisterVariable(m *Matcher, name string, variable interface{})

RegisterVariable registers a variable for dynamic size expressions

func RestBinary

func RestBinary(m *Matcher, variable interface{})

RestBinary adds a rest binary segment to the matcher

func RestBitstring

func RestBitstring(m *Matcher, variable interface{})

RestBitstring adds a rest bitstring segment to the matcher

func ToBinaryString

func ToBinaryString(bs *BitString) string

ToBinaryString converts a bitstring to binary string representation

func ToErlangFormat

func ToErlangFormat(bs *BitString) string

ToErlangFormat converts a bitstring to Erlang format

func ToFunbitFormat

func ToFunbitFormat(bs *BitString) string

ToFunbitFormat converts a bitstring to Funterm format with smart display

func ToHexDump

func ToHexDump(bs *BitString) string

ToHexDump converts a bitstring to hex dump format

func UTF

func UTF(m *Matcher, variable interface{}, options ...SegmentOption)

UTF adds a UTF segment to the matcher

func UTF8

func UTF8(m *Matcher, variable interface{}, options ...SegmentOption)

UTF8 adds a UTF-8 segment to the matcher

func UTF16

func UTF16(m *Matcher, variable interface{}, options ...SegmentOption)

UTF16 adds a UTF-16 segment to the matcher

func UTF32

func UTF32(m *Matcher, variable interface{}, options ...SegmentOption)

UTF32 adds a UTF-32 segment to the matcher

func ValidateSegment

func ValidateSegment(segment interface{}) error

ValidateSegment validates a segment

func ValidateSize

func ValidateSize(size uint, unit uint) error

ValidateSize validates the size and unit for a segment

func ValidateUnicodeCodePoint

func ValidateUnicodeCodePoint(codePoint int) error

ValidateUnicodeCodePoint validates a Unicode code point

Types

type BitString

type BitString = bitstringpkg.BitString

BitString represents a sequence of bits

func Build

func Build(b *Builder) (*BitString, error)

Build builds the bitstring from the builder

func NewBitString

func NewBitString() *BitString

NewBitString creates an empty bitstring

func NewBitStringFromBits

func NewBitStringFromBits(data []byte, length uint) *BitString

NewBitStringFromBits creates a bitstring from bits with specific length

func NewBitStringFromBytes

func NewBitStringFromBytes(data []byte) *BitString

NewBitStringFromBytes creates a bitstring from byte slice

type BitStringError

type BitStringError = bitstringpkg.BitStringError

BitStringError represents a bitstring error

func NewBitStringError

func NewBitStringError(code, message string) *BitStringError

NewBitStringError creates a new BitStringError with the given code and message

func NewBitStringErrorWithContext

func NewBitStringErrorWithContext(code, message string, context interface{}) *BitStringError

NewBitStringErrorWithContext creates a new BitStringError with the given code, message, and context

type Builder

type Builder = builder.Builder

Builder represents a bitstring builder

func NewBuilder

func NewBuilder() *Builder

NewBuilder creates a new builder instance

type Matcher

type Matcher = matcher.Matcher

Matcher represents a pattern matcher

func NewMatcher

func NewMatcher() *Matcher

NewMatcher creates a new matcher instance

type Segment

type Segment = bitstringpkg.Segment

Segment represents a segment in bitstring operations

func NewSegment

func NewSegment(value interface{}, options ...SegmentOption) *Segment

NewSegment creates a new segment

type SegmentOption

type SegmentOption = bitstringpkg.SegmentOption

SegmentOption represents an option for configuring segments

func WithDynamicSizeExpression

func WithDynamicSizeExpression(expression string) SegmentOption

WithDynamicSizeExpression sets a dynamic size expression for a segment

func WithEndianness

func WithEndianness(endianness string) SegmentOption

WithEndianness sets the endianness for a segment

func WithSigned

func WithSigned(signed bool) SegmentOption

WithSigned sets the signed flag for a segment

func WithSize

func WithSize(size uint) SegmentOption

WithSize sets the size for a segment

func WithType

func WithType(typeStr string) SegmentOption

WithType sets the type for a segment

func WithUnit

func WithUnit(unit uint) SegmentOption

WithUnit sets the unit for a segment

type SegmentResult

type SegmentResult = bitstringpkg.SegmentResult

SegmentResult represents the result of a matching operation

func Match

func Match(m *Matcher, bs *BitString) ([]SegmentResult, error)

Match performs the pattern matching

Jump to

Keyboard shortcuts

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