telemetry service and telemetry agents interface

This commit is contained in:
2026-03-05 16:26:30 +00:00
parent c9086cae56
commit e65358ea1d
16 changed files with 388 additions and 314 deletions
+22 -3
View File
@@ -11,9 +11,9 @@ type Vector struct {
DY uint16
}
type MultiError struct {
Errors []error
}
// type MultiError struct {
// Errors []error
// }
func B32(s string) [32]byte {
var b [32]byte
@@ -30,3 +30,22 @@ func StructToBytes(s any) ([]byte, error) {
return buf.Bytes(), nil
}
// func CopyBytes(dest []byte, destSize int, src string) {
// copy(dest[:], []byte(src))
// dest[min(destSize-1, len(src))] = '\x00'
// }
func CopyBytes(dest []byte, src string) {
// 1. Clear the destination (optional but safer for fixed-width telemetry)
for i := range dest {
dest[i] = 0
}
// 2. Copy as much as fits, leaving at least 1 byte for a null terminator
// We limit the copy to len(dest) - 1
n := copy(dest[:len(dest)-1], src)
// 3. Explicitly null terminate after the last written byte
dest[n] = '\x00'
}