diff options
Diffstat (limited to 'core/payload.go')
| -rw-r--r-- | core/payload.go | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/core/payload.go b/core/payload.go index be9d844..aad21ee 100644 --- a/core/payload.go +++ b/core/payload.go @@ -226,6 +226,55 @@ func DecodeHistory(buf io.Reader) (History, error) { return h, nil } +type List struct { + Count int64 + Offset int64 +} + +func (l List) Wrap() (PayloadType, []any) { + return PayloadList, []any{ + l.Count, + l.Offset, + } +} + +func DecodeList(buf io.Reader) (List, error) { + var l List + + err := decodeNumeric(buf, &l.Count) + if err != nil { + return l, err + } + + err = decodeNumeric(buf, &l.Offset) + if err != nil { + return l, err + } + + return l, nil +} + +type ListItem struct { + Address string +} + +func (l ListItem) Wrap() (PayloadType, []any) { + return PayloadListItem, []any{ + l.Address, + } +} + +func DecodeListItem(buf io.Reader) (ListItem, error) { + var l ListItem + + err := decodeString(buf, &l.Address) + if err != nil { + return l, err + } + + return l, nil +} + type Test struct { Num1 uint8 Time1 time.Time |
