Documentation
¶
Index ¶
- Constants
- Variables
- func ExpandFloats(data []byte) ([]float32, []byte, error)
- func ExpandInts(data []byte) ([]int32, []byte, error)
- func FloatArrayToBytes(s Storage) ([]byte, error)
- func FloatArrayToConn(w io.Writer, s Storage) error
- func FloatToBytes(s Storage) ([]byte, error)
- func FloatToConn(w io.Writer, s Storage) error
- func MixedArrayToBytes(s Storage) ([]byte, error)
- func MixedArrayToConn(w io.Writer, s Storage) error
- func NounToBytes(s Storage) ([]byte, error)
- func NounToConn(w io.Writer, s Storage) error
- func SqueezeBigInt(value []int32) []byte
- func SqueezeFloat32(value float32) []byte
- func SqueezeFloat64(value float64) []byte
- func SqueezeFloating(value Floating) []byte
- func SqueezeFloats(values []float32) []byte
- func SqueezeInt(value int32) []byte
- func SqueezeInts(values []int32) []byte
- func SqueezeVarint(v Varint) []byte
- func WordArrayToBytes(s Storage) ([]byte, error)
- func WordArrayToConn(w io.Writer, s Storage) error
- func WordToBytes(s Storage) ([]byte, error)
- func WordToConn(w io.Writer, s Storage) error
- type Conn
- func (c *Conn) ReadFloat() (float32, error)
- func (c *Conn) ReadFloat64() (float64, error)
- func (c *Conn) ReadFloatArray() ([]float32, error)
- func (c *Conn) ReadMixedArray() ([]Storage, error)
- func (c *Conn) ReadStorage() (Storage, error)
- func (c *Conn) ReadWord() (int32, error)
- func (c *Conn) ReadWordArray() ([]int32, error)
- func (c *Conn) ReadWordVarint() (Varint, error)
- func (c *Conn) SendTXOff() error
- func (c *Conn) SendTXOn() error
- func (c *Conn) TransmitFrequencies(frequencies []int64) error
- func (c *Conn) WriteFloat(value float32) error
- func (c *Conn) WriteFloat64(value float64) error
- func (c *Conn) WriteFloatArray(values []float32) error
- func (c *Conn) WriteMixedArray(values []Storage) error
- func (c *Conn) WriteStorage(s Storage) error
- func (c *Conn) WriteWord(value int32) error
- func (c *Conn) WriteWordArray(values []int32) error
- func (c *Conn) WriteWordWithType(value int32, objectType int) error
- func (c *Conn) WriteWords(values []int32) error
- type Floating
- type Storage
- func Float(value float32, objectType ...int) Storage
- func Float64(value float64, objectType ...int) Storage
- func FloatArray(values []float32, objectType ...int) Storage
- func FloatArrayFromBytes(data []byte, objectType int) (Storage, error)
- func FloatArrayFromConn(r io.Reader, objectType int) (Storage, error)
- func FloatFromBytes(data []byte, objectType int) (Storage, error)
- func FloatFromConn(r io.Reader, objectType int) (Storage, error)
- func FromBytes(data []byte, storageType, objectType int) (Storage, error)
- func Identity(s Storage) Storage
- func MakeFloat(value float32, objectType int) Storage
- func MakeFloat64(value float64, objectType int) Storage
- func MakeFloatArray(values []float32, objectType int) Storage
- func MakeMixedArray(values []Storage, objectType int) Storage
- func MakeWord(value int32, objectType int) Storage
- func MakeWordArray(values []int32, objectType int) Storage
- func MixedArray(values []Storage, objectType ...int) Storage
- func MixedArrayFromBytes(data []byte, objectType int) (Storage, error)
- func MixedArrayFromConn(r io.Reader, objectType int) (Storage, error)
- func Nil() Storage
- func NounFromConn(r io.Reader) (Storage, error)
- func ReadFromConn(r io.Reader) (Storage, error)
- func Word(value int32, objectType ...int) Storage
- func WordArray(values []int32, objectType ...int) Storage
- func WordArrayFromBytes(data []byte, objectType int) (Storage, error)
- func WordArrayFromConn(r io.Reader, objectType int) (Storage, error)
- func WordArrayNil() Storage
- func WordArrayNil1(s Storage) Storage
- func WordArrayNil2(s1, s2 Storage) Storage
- func WordFromBytes(data []byte, objectType int) (Storage, error)
- func WordFromConn(r io.Reader, objectType int) (Storage, error)
- func WordFromVarint(v Varint, objectType ...int) Storage
- func (s Storage) AsFloat() (float32, error)
- func (s Storage) AsFloat64() (float64, error)
- func (s Storage) AsFloats() ([]float32, error)
- func (s Storage) AsInt() (int32, error)
- func (s Storage) AsInts() ([]int32, error)
- func (s Storage) AsMixed() ([]Storage, error)
- func (s Storage) Equal(other Storage) bool
- func (s Storage) ToBytes() ([]byte, error)
- func (s Storage) Truth() int
- func (s Storage) WriteToConn(w io.Writer) error
- type Varint
Constants ¶
const ( // FloatTolerance is the tolerance for float matching. FloatTolerance = 1e-14 // FloatPrecision is the number of decimal places for formatting. FloatPrecision = 6 )
const ( StorageTypeWord = 0 StorageTypeFloat = 1 StorageTypeWordArray = 2 StorageTypeFloatArray = 3 StorageTypeMixedArray = 4 StorageTypeAny = 255 )
StorageType constants define the wire format type.
const ( NounTypeInteger = 0 NounTypeReal = 1 NounTypeCharacter = 2 NounTypeString = 3 NounTypeList = 4 NounTypeDictionary = 5 NounTypeBuiltinSymbol = 6 NounTypeBuiltinNilad = 7 NounTypeBuiltinMonad = 8 NounTypeBuiltinDyad = 9 NounTypeBuiltinTriad = 10 NounTypeMonadicAdverb = 11 NounTypeDyadicAdverb = 12 NounTypeTriadicAdverb = 13 NounTypeUserSymbol = 14 NounTypeUserNilad = 15 NounTypeUserMonad = 16 NounTypeUserDyad = 17 NounTypeUserTriad = 18 NounTypeError = 19 NounTypeExpression = 20 NounTypeType = 21 NounTypeConditional = 22 NounTypeQuotedSymbol = 23 NounTypeEffectType = 24 NounTypeResource = 25 NounTypeContingency = 26 NounTypeSignal = 27 NounTypeSequence = 28 NounTypeDependency = 29 NounTypeEffectExpression = 30 NounTypeLens = 31 NounTypeEffectChain = 32 NounTypeNiladicEffect = 33 NounTypeMonadicEffect = 34 NounTypeDyadicEffect = 35 NounTypeTriadicEffect = 36 NounTypeConjunction = 37 NounTypeData = 38 NounTypeSymbolDefinition = 39 NounTypeBindings = 40 NounTypeRange = 41 NounTypeAny = 255 )
NounType constants define the semantic type of the value.
const ( SymbolTypeI = 0 SymbolTypeX = 1 SymbolTypeY = 2 SymbolTypeZ = 3 SymbolTypeF = 4 SymbolTypeCausing = 5 SymbolTypeUndefined = 6 // Must always be last )
SymbolType constants for built-in symbols.
Variables ¶
var ( ErrEmptyData = errors.New("empty data") ErrInsufficientData = errors.New("insufficient data") ErrInvalidLength = errors.New("invalid length") )
var ( ErrUnknownStorageType = errors.New("unknown storage type") ErrTypeMismatch = errors.New("type mismatch") )
Functions ¶
func ExpandFloats ¶
ExpandFloats decodes an array of squeezed floats from a byte slice.
func ExpandInts ¶
ExpandInts decodes an array of squeezed integers from a byte slice.
func FloatArrayToBytes ¶
FloatArrayToBytes encodes a FloatArray to bytes (without type header). Format: [squeezed_length] [squeezed_float]...
func FloatArrayToConn ¶
FloatArrayToConn writes a FloatArray to a connection (with type header).
func FloatToBytes ¶
FloatToBytes encodes a Float to bytes (without type header).
func FloatToConn ¶
FloatToConn writes a Float to a connection (with type header).
func MixedArrayToBytes ¶
MixedArrayToBytes encodes a MixedArray to bytes (without type header). Format: [squeezed_length] ([storage_type] [object_type] [data])...
func MixedArrayToConn ¶
MixedArrayToConn writes a MixedArray to a connection (with type header).
func NounToBytes ¶
NounToBytes encodes any Storage value to bytes (without type header). This is the default implementation used by MixedArray.
func NounToConn ¶
NounToConn writes any Storage value to a connection (with type header). This is the default implementation used by MixedArray.
func SqueezeBigInt ¶
SqueezeBigInt encodes a big integer (multi-limb) value. Format: [length_byte] [data_bytes...] The input slice has sign as first element (0=positive, 1=negative), followed by the limbs in order.
func SqueezeFloat32 ¶
SqueezeFloat32 encodes a float32 value.
func SqueezeFloat64 ¶
SqueezeFloat64 encodes a float64 value.
func SqueezeFloating ¶
SqueezeFloating encodes a Floating value in IEEE format with length prefix. Format: [length_byte] [ieee_bytes...] - length 0: value is 0.0 - length 4: float32 (big-endian) - length 8: float64 (big-endian)
func SqueezeFloats ¶
SqueezeFloats encodes an array of floats. Format: [squeezed_length] [squeezed_float]...
func SqueezeInt ¶
SqueezeInt encodes an integer in the fewest number of bytes. Format: [length_byte] [data_bytes...] - Length byte: bits 0-6 = length, bit 7 = sign (1 = negative) - Data bytes: big-endian representation of absolute value Special case: 0 encodes as single byte [0x00]
func SqueezeInts ¶
SqueezeInts encodes an array of integers. Format: [squeezed_length] [squeezed_int]...
func WordArrayToBytes ¶
WordArrayToBytes encodes a WordArray to bytes (without type header). Format: [squeezed_length] [squeezed_int]...
func WordArrayToConn ¶
WordArrayToConn writes a WordArray to a connection (with type header).
func WordToBytes ¶
WordToBytes encodes a Word to bytes (without type header).
Types ¶
type Conn ¶
type Conn struct {
// contains filtered or unexported fields
}
Conn wraps an io.ReadWriter for ion protocol communication. It provides thread-safe read and write operations.
func NewConn ¶
func NewConn(rw io.ReadWriter) *Conn
NewConn creates a new ion connection from an io.ReadWriter. Typically used with a serial port connection.
func (*Conn) ReadFloat64 ¶
ReadFloat64 reads a float64 value. Thread-safe.
func (*Conn) ReadFloatArray ¶
ReadFloatArray reads a float array. Thread-safe.
func (*Conn) ReadMixedArray ¶
ReadMixedArray reads a mixed array. Thread-safe.
func (*Conn) ReadStorage ¶
ReadStorage reads a Storage value. Thread-safe.
func (*Conn) ReadWordArray ¶
ReadWordArray reads an integer array. Thread-safe.
func (*Conn) ReadWordVarint ¶
ReadWordVarint reads an integer that may be a BigInt. Thread-safe.
func (*Conn) TransmitFrequencies ¶
TransmitFrequencies sends a sequence of WSPR frequencies over the connection. This is the primary method for TX pipeline. Each frequency is sent as an ion Word (integer in centihertz).
func (*Conn) WriteFloat ¶
WriteFloat writes a float32 value. Thread-safe.
func (*Conn) WriteFloat64 ¶
WriteFloat64 writes a float64 value. Thread-safe.
func (*Conn) WriteFloatArray ¶
WriteFloatArray writes a float array. Thread-safe.
func (*Conn) WriteMixedArray ¶
WriteMixedArray writes a mixed array. Thread-safe.
func (*Conn) WriteStorage ¶
WriteStorage writes a Storage value. Thread-safe.
func (*Conn) WriteWordArray ¶
WriteWordArray writes an integer array. Thread-safe.
func (*Conn) WriteWordWithType ¶
WriteWordWithType writes an integer with a custom NounType. Thread-safe.
func (*Conn) WriteWords ¶
WriteWords writes multiple integer values sequentially. Thread-safe.
type Floating ¶
Floating represents either a float32 or float64.
func ExpandFloating ¶
ExpandFloating decodes a squeezed float from a byte slice. Returns the Floating value and remaining bytes.
func ExpandFloatingFromReader ¶
ExpandFloatingFromReader reads and decodes a squeezed float from an io.Reader.
type Storage ¶
type Storage struct {
ObjectType int // NounType - semantic type
StorageType int // StorageType - wire format type
Value interface{} // The actual value
}
Storage represents an ion value with type information.
func FloatArray ¶
FloatArray creates a float array Storage value.
func FloatArrayFromBytes ¶
FloatArrayFromBytes decodes a FloatArray from bytes (without type header). Format: [squeezed_length] [squeezed_float]...
func FloatArrayFromConn ¶
FloatArrayFromConn reads a FloatArray from a connection (without type header). The storageType and objectType have already been read.
func FloatFromBytes ¶
FloatFromBytes decodes a Float from bytes (without type header).
func FloatFromConn ¶
FloatFromConn reads a Float from a connection (without type header). The storageType and objectType have already been read.
func MakeFloat64 ¶
MakeFloat64 creates a Float Storage value from float64.
func MakeFloatArray ¶
MakeFloatArray creates a FloatArray Storage value.
func MakeMixedArray ¶
MakeMixedArray creates a MixedArray Storage value.
func MakeWord ¶
MakeWord creates a Word Storage value. This is an alias for Word() to match the C++ API.
func MakeWordArray ¶
MakeWordArray creates a WordArray Storage value.
func MixedArray ¶
MixedArray creates a mixed array Storage value.
func MixedArrayFromBytes ¶
MixedArrayFromBytes decodes a MixedArray from bytes (without type header). Format: [squeezed_length] ([storage_type] [object_type] [data])...
func MixedArrayFromConn ¶
MixedArrayFromConn reads a MixedArray from a connection (without type header). The storageType and objectType have already been read.
func NounFromConn ¶
NounFromConn reads any Storage value from a connection (with type header). This is the default implementation used by MixedArray.
func ReadFromConn ¶
ReadFromConn reads a Storage value from an io.Reader.
func WordArrayFromBytes ¶
WordArrayFromBytes decodes a WordArray from bytes (without type header). Format: [squeezed_length] [squeezed_int]...
func WordArrayFromConn ¶
WordArrayFromConn reads a WordArray from a connection (without type header). The storageType and objectType have already been read.
func WordArrayNil1 ¶
WordArrayNil1 creates an empty WordArray (ignoring input).
func WordArrayNil2 ¶
WordArrayNil2 creates an empty WordArray (ignoring inputs).
func WordFromBytes ¶
WordFromBytes decodes a Word from bytes (without type header).
func WordFromConn ¶
WordFromConn reads a Word from a connection (without type header). The storageType and objectType have already been read.
func WordFromVarint ¶
WordFromVarint creates a Storage from a Varint. If the Varint is a BigInt, it stores the limbs as []int32.
type Varint ¶
type Varint struct {
IsInt bool
Int int32
BigInt []int32 // [sign, limb0, limb1, ...] where sign is 0 (positive) or 1 (negative)
}
Varint represents either a regular int32 or a big integer (slice of int32 limbs). For big integers, the first element is the sign (0 = positive, 1 = negative), followed by the limbs in big-endian order.
func ExpandInt ¶
ExpandInt decodes a squeezed integer from a byte slice. Returns the decoded Varint and remaining bytes. If the value fits in int32, IsInt will be true. Otherwise, BigInt will contain [sign, limbs...].
func ExpandIntFromBytes ¶
ExpandIntFromBytes expands an integer from raw bytes (no length prefix, no sign). This is used when the bytes are already extracted.
func ExpandIntFromReader ¶
ExpandIntFromReader reads and decodes a squeezed integer from an io.Reader.
func NewVarintBigInt ¶
NewVarintBigInt creates a Varint from a big integer representation. The first element should be the sign (0 or 1), followed by limbs.