builder

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: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppendToBitString

func AppendToBitString(target *bitstring.BitString, segments ...bitstring.Segment) (*bitstring.BitString, error)

AppendToBitString appends segments to an existing bitstring. Since BitString is immutable, this returns a new BitString with the appended data.

func BuildBitStringDynamically

func BuildBitStringDynamically(generator func() ([]bitstring.Segment, error)) (*bitstring.BitString, error)

BuildBitStringDynamically builds a bitstring using a generator function that returns segments dynamically. This allows for construction in loops and other dynamic scenarios.

func BuildConditionalBitString

func BuildConditionalBitString(condition bool, trueSegments, falseSegments []bitstring.Segment) (*bitstring.BitString, error)

BuildConditionalBitString builds a bitstring based on a condition. If condition is true, uses trueSegments, otherwise uses falseSegments.

Types

type Builder

type Builder struct {
	// contains filtered or unexported fields
}

Builder provides a fluent interface for constructing bitstrings

func NewBuilder

func NewBuilder() *Builder

NewBuilder creates a new builder instance

func (*Builder) AddBinary

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

AddBinary adds a binary segment to the builder

func (*Builder) AddBitstring

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

AddBitstring adds a nested bitstring segment to the builder

func (*Builder) AddFloat

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

AddFloat adds a float segment to the builder

func (*Builder) AddInteger

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

AddInteger adds an integer segment to the builder

func (*Builder) AddSegment

func (b *Builder) AddSegment(segment bitstring.Segment) *Builder

AddSegment adds a generic segment to the builder

func (*Builder) Build

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

Build constructs the final bitstring from all segments

func (*Builder) SetError

func (b *Builder) SetError(err error)

SetError sets the first error encountered (public method for external use)

type CustomInt

type CustomInt interface {
	ToInt() int
}

CustomInt interface for testing reflection paths

type MyInt

type MyInt struct {
	// contains filtered or unexported fields
}

MyInt implements CustomInt interface for testing

func (MyInt) ToInt

func (m MyInt) ToInt() int

Jump to

Keyboard shortcuts

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