Documentation
¶
Index ¶
- type Header
- type Parameter
- func (p Parameter) ArrayValue() iter.Seq2[int, any]
- func (p Parameter) BooleanArrayValue() iter.Seq2[int, bool]
- func (p Parameter) BooleanValue() (bool, bool)
- func (p Parameter) ByteArrayValue() iter.Seq2[int, byte]
- func (p Parameter) DictionaryValue() iter.Seq2[any, any]
- func (p Parameter) Float32ArrayValue() iter.Seq2[int, float32]
- func (p Parameter) Float32Value() (float32, bool)
- func (p Parameter) Float64Value() (float64, bool)
- func (p Parameter) ID() uint8
- func (p Parameter) Int8ArrayValue() iter.Seq2[int, int8]
- func (p Parameter) Int16ArrayValue() iter.Seq2[int, int16]
- func (p Parameter) Int32ArrayValue() iter.Seq2[int, int32]
- func (p Parameter) Int64ArrayValue() iter.Seq2[int, int64]
- func (p Parameter) IntValue() (int64, bool)
- func (p Parameter) MarshalJSON() ([]byte, error)
- func (p *Parameter) ParseInto(reader *reader.Reader, hooks *hooks.Hooks[Parameter], dest *Parameter) error
- func (p Parameter) StringArrayValue() iter.Seq2[int, string]
- func (p Parameter) StringValue() (string, bool)
- type ParameterType
- type ReliableHeaderParameterCountV18
- type Value
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Header ¶
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 ¶
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) BooleanValue ¶
func (Parameter) Float32Value ¶
func (Parameter) Float64Value ¶
func (Parameter) MarshalJSON ¶
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) StringValue ¶
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{}
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
}