Cbor.decode: def of bend-kit-cbor@0.3.0.0 Import: import bend-kit-cbor@0.3.0.0/cbor.bend as Cbor Lines 779-785 of bend-kit-cbor@0.3.0.0/cbor.bend: https://jend.leeeet.dev/read.txt?path=bend-kit-cbor@0.3.0.0/cbor.bend&start_line=779&end_line=785 import Base import bend-kit-bytes@0.3.3.0/bytes.bend as Bytes # One well-formed data item (RFC 8949 ยง3, Appendix C) filling b. Indefinite strings, arrays and maps come back # definite, with chunks joined. None for truncation, reserved ai 28..30, a misplaced break or indefinite form, # a simple value 0..31 in two bytes, text that is not UTF-8, or trailing bytes. # fuel: a head or chunk eats a byte, and each SDone step follows one, so 2 * len + 2 steps are enough. def decode(b: Bytes.Bytes) -> Maybe<&1, Val>: Bytes.Bytes{+len, buf} = b run(Nat.add(Nat.mul(U32.to_nat(len), 2n), 2n), (buf, SHead{0, Nil{}}), len) Uses (10): https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=List https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Maybe https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Nat.add https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Nat.mul https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Sigma https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32.to_nat https://jend.leeeet.dev/definition.txt?path=bend-kit-bytes@0.3.3.0/bytes.bend&name=Bytes https://jend.leeeet.dev/definition.txt?path=bend-kit-cbor@0.3.0.0/cbor.bend&name=St https://jend.leeeet.dev/definition.txt?path=bend-kit-cbor@0.3.0.0/cbor.bend&name=Val https://jend.leeeet.dev/definition.txt?path=bend-kit-cbor@0.3.0.0/cbor.bend&name=run