v18

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 17, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Header struct {
	ID   uint8         `json:"id"`   // Parameter identifier (application-specific)
	Type ParameterType `json:"type"` // Protocol16 type code indicating how to decode the value
}

Header represents the parameter header containing the parameter ID and type. This appears at the beginning of each serialized parameter.

type Parameter

type Parameter struct {
	Header `json:"header"`
	Value  `json:"value"`
}

Parameters represents a complete Photon Protocol parameter with its header and decoded value. The Value field contains the decoded data according to the Type specified in the Header.

func (Parameter) ArrayValue

func (p Parameter) ArrayValue() iter.Seq2[int, any]

func (Parameter) BooleanArrayValue

func (p Parameter) BooleanArrayValue() iter.Seq2[int, bool]

func (Parameter) BooleanValue

func (p Parameter) BooleanValue() (bool, bool)

func (Parameter) ByteArrayValue

func (p Parameter) ByteArrayValue() iter.Seq2[int, byte]

func (Parameter) DictionaryValue

func (p Parameter) DictionaryValue() iter.Seq2[any, any]

func (Parameter) Float32ArrayValue

func (p Parameter) Float32ArrayValue() iter.Seq2[int, float32]

func (Parameter) Float32Value

func (p Parameter) Float32Value() (float32, bool)

func (Parameter) Float64Value

func (p Parameter) Float64Value() (float64, bool)

func (Parameter) ID

func (p Parameter) ID() uint8

func (Parameter) Int8ArrayValue

func (p Parameter) Int8ArrayValue() iter.Seq2[int, int8]

func (Parameter) Int16ArrayValue

func (p Parameter) Int16ArrayValue() iter.Seq2[int, int16]

func (Parameter) Int32ArrayValue

func (p Parameter) Int32ArrayValue() iter.Seq2[int, int32]

func (Parameter) Int64ArrayValue

func (p Parameter) Int64ArrayValue() iter.Seq2[int, int64]

func (Parameter) IntValue

func (p Parameter) IntValue() (int64, bool)

func (Parameter) MarshalJSON

func (p Parameter) MarshalJSON() ([]byte, error)

func (*Parameter) ParseInto added in v1.0.0

func (p *Parameter) ParseInto(reader *reader.Reader, hooks *hooks.Hooks[Parameter], dest *Parameter) error

Parse reads a complete parameter from the reader. Format: Header (1 byte ID + 1 byte Type), followed by the typed value.

The function first reads the parameter header to determine the parameter ID and type code, then decodes the value according to that type using the Protocol16 decoder.

Returns a Parameters struct containing the ID, Type, and decoded Value, or an error if parsing fails.

Example usage:

param, err := parameters.Parse(reader)
if err != nil {
    return err
}
fmt.Printf("Parameter %d has value: %v\n", param.ID, param.Value)

func (Parameter) StringArrayValue

func (p Parameter) StringArrayValue() iter.Seq2[int, string]

func (Parameter) StringValue

func (p Parameter) StringValue() (string, bool)

type ParameterType

type ParameterType uint8
const (
	UnknownType         ParameterType = 0 //Tested
	BooleanType         ParameterType = 2
	Int8Type            ParameterType = 3
	Int16Type           ParameterType = 4 //Tested
	Float32Type         ParameterType = 5
	Float64Type         ParameterType = 6
	StringType          ParameterType = 7 //Tested
	NilType             ParameterType = 8
	CompressedInt32Type ParameterType = 9  //Tested
	CompressedInt64Type ParameterType = 10 //Tested

	Int8Positive  ParameterType = 11 // 1 byte unsigned, cast to +int32
	Int8Negative  ParameterType = 12 // 1 byte unsigned, cast to -int32
	Int16Positive ParameterType = 13 // 2 bytes unsigned, cast to +int32 Tested
	Int16Negative ParameterType = 14 // 2 bytes unsigned, cast to -int32

	Long8Positive  ParameterType = 15 // 1 byte unsigned, cast to +int64
	Long8Negative  ParameterType = 16 // 1 byte unsigned, cast to -int64
	Long16Positive ParameterType = 17 // 2 bytes unsigned, cast to +int64
	Long16Negative ParameterType = 18 // 2 bytes unsigned, cast to -int64

	CustomType     ParameterType = 19
	CustomTypeSlim ParameterType = 0x80

	// Complex types
	DictionaryType        ParameterType = 20
	HashtableType         ParameterType = 21
	ObjectArrayType       ParameterType = 23
	OperationRequestType  ParameterType = 24
	OperationResponseType ParameterType = 25
	EventDataType         ParameterType = 26

	// Zero shorthands — no payload bytes, type code is the entire value
	BooleanFalseType ParameterType = 27
	BooleanTrueType  ParameterType = 28
	ShortZeroType    ParameterType = 29
	IntZeroType      ParameterType = 30
	LongZeroType     ParameterType = 31
	FloatZeroType    ParameterType = 32
	DoubleZeroType   ParameterType = 33
	ByteZeroType     ParameterType = 34 //Tested

	// Array container — element count + element type follows
	ArrayType ParameterType = 0x40

	// Typed arrays — element type is baked into the type code (elemType | 0x40)
	BooleanArrayType        ParameterType = BooleanType | ArrayType         // 0x42
	ByteArrayType           ParameterType = Int8Type | ArrayType            // 0x43
	ShortArrayType          ParameterType = Int16Type | ArrayType           // 0x44 Tested
	Float32ArrayType        ParameterType = Float32Type | ArrayType         // 0x45 Tested
	Float64ArrayType        ParameterType = Float64Type | ArrayType         // 0x46
	StringArrayType         ParameterType = StringType | ArrayType          // 0x47
	CompressedIntArrayType  ParameterType = CompressedInt32Type | ArrayType // 0x49
	CompressedLongArrayType ParameterType = CompressedInt64Type | ArrayType // 0x4A
	CustomTypeArrayType     ParameterType = CustomType | ArrayType          // 0x53
	DictionaryArrayType     ParameterType = DictionaryType | ArrayType      // 0x54
	HashtableArrayType      ParameterType = HashtableType | ArrayType       // 0x55
)

type ReliableHeaderParameterCountV18

type ReliableHeaderParameterCountV18 struct{}

func (ReliableHeaderParameterCountV18) Count

type Value

type Value struct {
	Kind    ParameterType `json:"kind"`
	KeyType ParameterType `json:"key_type"`
	ValType ParameterType `json:"val_type"`

	Num  uint64 `json:"num"`
	Blob []byte `json:"blob,omitempty"`
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

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