tape: Add DecodeVILAIter

This commit is contained in:
Sasha Koshka 2025-05-22 23:44:20 -04:00
parent 2b3a53052f
commit 32df336c3e

View File

@ -69,6 +69,19 @@ func DecodeVILA(data []byte) ArrayPullFunc {
} }
} }
// DecodeVILAIter decodes a variable item length array and returns it as an
// iterator.
func DecodeVILAIter(data []byte) iter.Seq[[]byte] {
return func(yield func([]byte) bool) {
pull := DecodeVILA(data)
for {
value, _, err := pull()
if err != nil { return }
if !yield(value) { return }
}
}
}
// EncodeVILA encodes a variable item length array. // EncodeVILA encodes a variable item length array.
func EncodeVILA(data []byte, items ...[]byte) ArrayPushFunc { func EncodeVILA(data []byte, items ...[]byte) ArrayPushFunc {
n := 0 n := 0