tape: Add DecodeVILAIter
This commit is contained in:
parent
2b3a53052f
commit
32df336c3e
@ -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
|
||||||
|
Loading…
Reference in New Issue
Block a user