def decode
import bend-kit-redis@0.3.0.0/redis.bend as Redisimport Base
import bend-kit-bytes@0.3.3.0/bytes.bend as Bytes
629# One reply starting at byte i of b. Every item takes at least 3 bytes and each step
630# reads an item or closes one, so 2 * (len - i) + 2 steps are enough.
631def decode(b: Bytes.Bytes, +i: U32) -> Bytes.Bytes & Step:
632 Bytes.Bytes{+len, buf} = b
633 run(Nat.add(Nat.mul(U32.to_nat((len - i : U32)), 2n), 2n), (Bytes.Bytes{len, buf}, SHead{i, Nil{}}))