simplified a bit how the TelemetryField updaters work

- now we only use one function to update the TelemetryField instead
of having to fetch data and then update it.

Still need to update the iRacing provider to use this pattern. Way
better and creates better units.

Got rid of that stupid long ass switch statement too
This commit is contained in:
2026-07-07 17:52:47 +01:00
parent 94ba0e2539
commit 0887fbfd75
6 changed files with 181 additions and 281 deletions
+9 -3
View File
@@ -32,10 +32,11 @@ type VirtualField interface {
// NOTE: we must deprecate the `Key` member. We used it to map the internal
// telemetry fields to the providers name. But we shouldn't be using `string` keys.
type BoundField struct {
Key string
Key string // to be deprecated
ID FieldID
Fetch func() any
Transform func(any, *TelemetryField)
Fetch func() any // to be deprecated
Transform func(any, *TelemetryField) // to be deprecated
Update func(out *TelemetryField)
}
var bufferPool = sync.Pool{
@@ -74,6 +75,11 @@ type TelemetryField struct {
Str string // Only to be used with DataTypeSTRING
}
func (tf *TelemetryField) Unused() {
tf.Type = DataTypeCHAR
tf.Raw = uint64('-')
}
// Pack will pack this current TelemetryField into bytes to send over the wire
// Format:
// 0x00 - Field ID